remember previous settings with page loads

remember previous settings with page loads

jackalbrightjackalbright Posts: 14Questions: 4Answers: 0
edited February 2013 in DataTables 1.9
I would like datatables to go to the state it was in the last time I had the page open. The parameters I'm interested in are Page, Sort Column, Sort Direction, and Previous Search Criteria.

I see that I can use fnPageChange() to go to the page. The others I have not figured out yet.

Also, I see that there is a function called fnSettings(), Is this the function I need to call to get the Sort, Search, and Page info that I need? I looked at the output of fnSettings() and I'm not real sure which values I should grab.

Thanks,
Jack

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Perhaps the bStateSave option would do what you want?

    Allan
  • jackalbrightjackalbright Posts: 14Questions: 4Answers: 0
    When I add bStateSave, it completely breaks DataTables. The page loads but my data is just a raw table. My DataTables version is 1.9.0.

    The error I get is:
    TypeError: j is undefined (in datatables.min.js)

    Here's how I enable bStateSave:

    oTable = jQuery('#subscriptionTable_dataTable').dataTable({
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "bStateSave": true,
    "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
    "oTableTools": {
    "aButtons": [
    "print"
    ]
    }
    });
  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Looks find to me - can you link to the page so I can debug it please? Also, try clearing your cookie just incase something duff is stored in a current cookie.

    Allan
  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Oh and update to 1.9.4 :-)

    Allan
This discussion has been closed.