Since: DataTables 1.10.1

Get the last saved state of the table.


When state saving is enabled (stateSave) it can be useful to know what state has been saved for a table an any one specific moment. This method provides the ability to get the last data object that has been stored in by the state saving mechanism.

The data object has the following format, but please be aware that plug-ins and extensions to DataTables can modify this structure by adding data as they require for their own state information.

    "time":   {number}               // Time stamp of when the object was created
    "start":  {number}               // Display start point
    "length": {number}               // Page length
    "order":  {array}                // 2D array of column ordering information (see `order` option)
    "search": {
        "search":          {string}  // Search term
        "regex":           {boolean} // Indicate if the search term should be treated as regex or not
        "smart":           {boolean} // Flag to enable DataTables smart search
        "caseInsensitive": {boolean} // Case insensitive flag
    "columns" [
            "visible": {boolean}     // Column visibility
            "search":  {}            // Object containing column search information. Same structure as `search` above

Please note that this method gives the last saved state, which is not necessarily the current state. For example the page() method will not automatically trigger a state save. Calling draw() will trigger a state save, or use state.save().


function state()


Get the last saved state of the table


State saved object


Get the saved page length from the state object:

alert( 'Saved page length is: '+ table.state().length );


The following options are directly related and may also be useful in your application development.