Gridx in XPages – 21: Maintaining Grid State Between Sessions

Users often want to maintain the state of a data display so it can be automatically restored the next time they view that page. The Persist module of Gridx does just that. Simply by adding the module to the grid, settings are preserved between sessions. In this post, I’ll show how to add it and list several features that are persisted.

Gridx Series

Gridx in XPages — Entire Series


The Persist module stores information about the state of the grid when you leave the page. This way, the user returns to the grid the way they left it — even between sessions. (It uses a cookie to maintain the state and restore it.)

I tested it with the following features and found that it preserved them all:

  • Sorting (single and nested)
  • Column Widths
  • Filtering
  • Reordered Columns
  • Hidden Columns

1. Require Module

The first thing you need to do is include the Persist module in the require statement.


2. Include Module in Grid

To make it available to the grid, add it to the grid’s modules list.

modules: [  

That’s it — it just works!

Restoring to Original State

If you want to restore the grid to its original state, you can do so, but setting the enabled property to false via client-side JavaScript.


Then you need to reload the page. Nothing happens automatically, but when the grid is re-rendered, it will be back to its default layout.

Note: It can be done more efficiently by destroying and re-creating the grid rather than reloading the entire page.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: