1
votes

The stateSave in jQuery DataTables is not working when loading data table for the first time, it loads filter data of previous state. It works fine after first load.

For example- If I have performed filter search and logout & login again in the application or update the cache and load this data table again then filter value of previous search will be visible and if there was nothing in previous search then value of filter will be blank. And next search onwards the filter works fine.

jQuery('#tableName').dataTable( {
    "Destroy": true,
    "Paginate": true,
    "StateSave": true,
    "StateDuration": 0.1
});
1

1 Answers

1
votes

stateDuration defines the mode of storage as well as the duration in seconds after which the saved state will be invalidated. This should be an integer (see https://datatables.net/reference/option/stateDuration), so the behaviour with provided value 0.1 is undefined.

All the options are named in camelCase. Paginate does not exist, you probably mean paging.

jQuery('#tableName').dataTable( {
    destroy: true,
    paging: true,
    stateSave: true,
    stateDuration: -1
});

Fiddle

For an overview of all the options see https://datatables.net/reference/option/.