DataTables has the option of being able to save the state of a table (its paging position, sorting state
etc) so that is can be restored when the user reloads a page, or comes back to it after visiting a sub-page.
This state saving ability is enabled by the stateSave
option.
The built in state saving method uses the HTML5 localStorage
API for efficient storage of the
data. PLease note that this means that the built in state saving option will not work with IE6/7 as these
browsers do not support this API. Alternative options of using cookies or saving the state on the server
through Ajax can be used through the stateSaveCallback
and stateLoadCallback
options.
Additionally, note also that the duration for which the saved state is valid and can be used to restore the
table state can be set using the stateDuration
initialisation parameter (2 hours by default).
The example below simply shows state saving enabled in DataTables with the saveSave
option.
Name | Age | Position | Office | Start date | Salary |
---|---|---|---|---|---|
Name | Age | Position | Office | Start date | Salary |
Tiger Nixon | 61 | System Architect | Edinburgh | 2011/04/25 | $3,120 |
Garrett Winters | 63 | Director | Edinburgh | 2011/07/25 | $5,300 |
Ashton Cox | 66 | Technical Author | San Francisco | 2009/01/12 | $4,800 |
Cedric Kelly | 22 | Javascript Developer | Edinburgh | 2012/03/29 | $3,600 |
Jenna Elliott | 33 | Financial Controller | Edinburgh | 2008/11/28 | $5,300 |
Brielle Williamson | 61 | Integration Specialist | New York | 2012/12/02 | $4,525 |
Herrod Chandler | 59 | Sales Assistant | San Francisco | 2012/08/06 | $4,080 |
Rhona Davidson | 55 | Integration Specialist | Edinburgh | 2010/10/14 | $6,730 |
Colleen Hurst | 39 | Javascript Developer | San Francisco | 2009/09/15 | $5,000 |
Sonya Frost | 23 | Software Engineer | Edinburgh | 2008/12/13 | $3,600 |
Jena Gaines | 30 | System Architect | London | 2008/12/19 | $5,000 |
Quinn Flynn | 22 | Financial Controller | Edinburgh | 2013/03/03 | $4,200 |
Charde Marshall | 36 | Regional Director | San Francisco | 2008/10/16 | $5,300 |
Haley Kennedy | 43 | Senior Marketing Designer | London | 2012/12/18 | $4,800 |
Tatyana Fitzpatrick | 19 | Regional Director | London | 2010/03/17 | $2,875 |
Michael Silva | 66 | Senior Marketing Designer | London | 2012/11/27 | $3,750 |
Paul Byrd | 64 | Javascript Developer | New York | 2010/06/09 | $5,000 |
Gloria Little | 59 | Systems Administrator | New York | 2009/04/10 | $3,120 |
Bradley Greer | 41 | Software Engineer | London | 2012/10/13 | $3,120 |
Dai Rios | 35 | System Architect | Edinburgh | 2012/09/26 | $4,200 |
Jenette Caldwell | 30 | Financial Controller | New York | 2011/09/03 | $4,965 |
Yuri Berry | 40 | System Architect | New York | 2009/06/25 | $3,600 |
Caesar Vance | 21 | Technical Author | New York | 2011/12/12 | $4,965 |
Doris Wilder | 23 | Sales Assistant | Edinburgh | 2010/09/20 | $4,965 |
Angelica Ramos | 36 | System Architect | London | 2009/10/09 | $2,875 |
Gavin Joyce | 42 | Developer | Edinburgh | 2010/12/22 | $4,525 |
Jennifer Chang | 28 | Regional Director | London | 2010/11/14 | $4,080 |
Brenden Wagner | 18 | Software Engineer | San Francisco | 2011/06/07 | $3,750 |
Ebony Grimes | 48 | Software Engineer | San Francisco | 2010/03/11 | $2,875 |
Russell Chavez | 20 | Director | Edinburgh | 2011/08/14 | $3,600 |
Michelle House | 37 | Integration Specialist | Edinburgh | 2011/06/02 | $3,750 |
Suki Burks | 53 | Developer | London | 2009/10/22 | $2,875 |
Prescott Bartlett | 27 | Technical Author | London | 2011/05/07 | $6,730 |
Gavin Cortez | 22 | Technical Author | San Francisco | 2008/10/26 | $6,730 |
Martena Mccray | 46 | Integration Specialist | Edinburgh | 2011/03/09 | $4,080 |
Unity Butler | 47 | Senior Marketing Designer | San Francisco | 2009/12/09 | $3,750 |
Howard Hatfield | 51 | Financial Controller | San Francisco | 2008/12/16 | $4,080 |
Hope Fuentes | 41 | Financial Controller | San Francisco | 2010/02/12 | $4,200 |
Vivian Harrell | 62 | System Architect | San Francisco | 2009/02/14 | $4,965 |
Timothy Mooney | 37 | Financial Controller | London | 2008/12/11 | $4,200 |
Jackson Bradshaw | 65 | Director | New York | 2008/09/26 | $5,000 |
Miriam Weiss | 64 | Support Engineer | Edinburgh | 2011/02/03 | $4,965 |
Bruno Nash | 38 | Software Engineer | London | 2011/05/03 | $4,200 |
Odessa Jackson | 37 | Support Engineer | Edinburgh | 2009/08/19 | $3,600 |
Thor Walton | 61 | Developer | New York | 2013/08/11 | $3,600 |
Finn Camacho | 47 | Support Engineer | San Francisco | 2009/07/07 | $4,800 |
Elton Baldwin | 64 | Data Coordinator | Edinburgh | 2012/04/09 | $6,730 |
Zenaida Frank | 63 | Software Engineer | New York | 2010/01/04 | $4,800 |
Zorita Serrano | 56 | Software Engineer | San Francisco | 2012/06/01 | $5,300 |
Jennifer Acosta | 43 | Javascript Developer | Edinburgh | 2013/02/01 | $2,875 |
Cara Stevens | 46 | Sales Assistant | New York | 2011/12/06 | $4,800 |
Hermione Butler | 47 | Director | London | 2011/03/21 | $4,080 |
Lael Greer | 21 | Systems Administrator | London | 2009/02/27 | $3,120 |
Jonas Alexander | 30 | Developer | San Francisco | 2010/07/14 | $5,300 |
Shad Decker | 51 | Regional Director | Edinburgh | 2008/11/13 | $5,300 |
Michael Bruce | 29 | Javascript Developer | Edinburgh | 2011/06/27 | $4,080 |
Donna Snider | 27 | System Architect | New York | 2011/01/25 | $3,120 |