XPages Data Views – Part 6: Pager Save State Control
The Pager Save State control is another great feature available to work with a Data View. It allows you to restore the expand/collapse state of each element in the view to the state the user last left it.
Data View Series
- Part 1 – Overview
- Part 2 – Creating a Data View
- Part 3 – Collapsible Details
- Part 4 – Icon Columns
- Part 5 – Pager Add Rows Control
By default, any time you open a Data View, it will open with all categories and details sections collapsed, regardless of any changes that the user made to the state previously. With the Pager Save State control, it’s easy to maintain the previous state and restore it when the user returns to the view.
Adding the Control
1. Drag and drop a Pager Save State control onto the page from the the Extension Library section of the controls palette.
It looks like a gold 3.5″ floppy disk icon in Domino Designer.
2. Set the for property of the control to the id of the Data View.
Using the Control
3. To make use of the control, you need to execute a single line of SSJS that will make use of the Pager Save State Bean that the control provides and restores the view state.
viewStateBean.restoreState = true;
Just call this before re-opening the Data View and it will restore the state as it was left. If the user has used the Pager Add Rows control to add more rows to the view, it will also restore the same number of rows that were last displayed.
In addition to working if you’re using SSJS to return to the view, you can make it work if you’re using Simple Actions as well. For example, if you’re using an Open Page Simple Action to return to the view, you can add an Execute Script simple action before it that contains that one line of code.
In the next post, we’ll take a look at how to take your Data View UI to the next level by customizing the Summary section.