blob: 50e943c34a819a87432977dacc173057a9d81fea [file] [log] [blame]
<div id="midcolumn">
<h3>Save settings / Persistence</h3>
<div id="doccontent">
<div class="chapter">
<div class="content">
<p>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:</p>
<ol>
<li>Hidden columns</li>
<li>Column order</li>
<li>Resized columns/rows</li>
<li>Sorting state</li>
<li>Column groups state</li>
<li>Filter row state</li>
</ol>
<p>The PersistentNatExample is a good place to get started.</p>
<h6>Saving state</h6>
<p>NatTable saves its state in a <span class="code">java.util.Properties</span> file as key/value pairs.
The main method to note is the</p>
<div class="codeBlock">NatTable.saveState(prefix, properties)</div>
<p>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.</p>
<h6>Loading state</h6>
<p>The method to note is the</p>
<div class="codeBlock">NatTable.loadState(String prefix, Properties properties)</div>
<p>The prefix and properties file are from the save state step.</p>
</div>
</div>
<div class="chapter">
<h5>Saving your custom state</h5>
<div class="content">
<p>The <span class="code">IPersistable</span> 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
<span class="code">registerPersistable()</span> on the <span class="code">ILayer</span> interface. Your persistable will
be invoked when NatTable state is saved/loaded.</p>
<img align="middle" src="images/persistable.png" border="0" alt="NatTable persistable diagram"/>
</div>
</div>
</div>
</div>