Save settings / Persistence
NatTable settings refer to the changes which the user makes to the grid while using it. The settings which are saved include but are not limited to the following:
- Hidden columns
- Column order
- Resized columns/rows
- Sorting state
- Column groups state
- Filter row state
The PersistentNatExample is a good place to get started.
NatTable saves its state in a java.util.Properties file as key/value pairs. The main method to note is the
To save state, invoke this method and give it a properties file. This file will be populated with all the sate information. You can now save this file anywhere/anyway you wish. Prefix is any arbitrary string which will be prepended to all the key values in the property file.
The method to note is the
The prefix and properties file are from the save state step.
Saving your custom state
The IPersistable interface is the main interface to note. All the layers which save state, implement this interface. Additionally, you can register your own persistable with any layer using the registerPersistable() on the ILayer interface. Your persistable will be invoked when NatTable state is saved/loaded.