Datatables use stateSave but override displayStart

Datatables use stateSave but override displayStart

postitiefpostitief Posts: 22Questions: 9Answers: 0
edited April 2015 in Free community support

I'm using datatables and the saveState feature. This is working fine, but in my table, the content inside the table is not always the same. I mean, that in the same table, I can load content of customer A and also switch to content of customer B. Customer B can have 200 rows, while customer A only has 40 rows.

If I set the result to customer B, I get 200 rows, devided over 20 pages (10 results per page). When I am on page 20, and switch to customer A, I don't see anything because it loads data starting at 180 (serverSide). And A only has 40 rows. But when the page is loaded again, it must always load page 1.

Actually, from the stateSave function, I only need it to remember the pageLength. How can I fix this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,933Questions: 1Answers: 10,352 Site admin
    Answer ✓

    Use stateSaveParams to delete what you don't want.

    Allan

  • postitiefpostitief Posts: 22Questions: 9Answers: 0

    Awesome!

    I now initialized it like:

    "stateSave": true,
    "stateDuration": 3600 * 24 * 7,
    "stateSaveParams": function (setting, data){
        data.start = 0;
    }
    
This discussion has been closed.