Manohar
Manohar

Reputation: 29

How to handle the page index selection in Jquery DataTables

We have a table of data with columns like CaseId, name.. etc. Here Case Id is an hyper link. we are using the Jquery DataTables to display data. Here Issue is, If I am in page number 3 and clicking on any CaseId link here, It will redirect to cases page. Here if I click on back button it should display the page 3 data and it will select page number 3. But In my case it is going to page 1. I had handled the data level which is displaying page 3 data but here it's selecting the page number as 1. How to fix this... Can any one help me on this.

Upvotes: 0

Views: 423

Answers (1)

Ogreucha
Ogreucha

Reputation: 688

You can use the 'stateSave' option to save the state of your dataTable.

$(document).ready(function() {
    $('#example').DataTable( {
        stateSave: true
    } );
} );

DataTables has the option of being able to save the state of a table (its paging position, ordering state etc) so that is can be restored when the user reloads a page, or comes back to the page after visiting a sub-page. This state saving ability is enabled by the stateSave option.

See https://datatables.net/examples/basic_init/state_save.html for more info.

Upvotes: 1

Related Questions