How to reset jquery datatable bStateSave for next record lookup

I am using jquery datatable to display a list of records.

The workflow for this problem is as follows:

  • The user enters a "test" in the search field. it will return a list of customer name.
  • After clicking on the next button with datatable data, it displays the next 10 records.
  • When I click on the client name, it displays the client information.
  • after clicking on the browser return button, it returns to the list of clients. but it goes back to 1 page instead of 2 pages. For this problem, I used "bStateSave = true" (presumably saving the state for reloading), which keeps the user on the second page. this is normal.

Here is our problem:

But when the user switches to another search in the search field and enters text, he displays page 2. However, the user wants to see page 1 first, since he posted a new request.

I tried "iCookieDuration = 60" to clear bStateSave. but it clears after 60 seconds.

Is there an alternative way to achieve both things?

+4
source share
1 answer

Your use case works for me using jQuery DataTables version 1.7.6. Today I just started using the same option as you to save the state of the table in a cookie. I do not use any other initialization parameters, as you can see below.

$(document).ready(function() { $('#charts').dataTable( { "bStateSave": true }); }); 
+3
source

Source: https://habr.com/ru/post/1446139/


All Articles