Pagination question

Pagination question

brilangbrilang Posts: 22Questions: 2Answers: 1
edited May 2009 in General
I've got a table using DataTables. All is good.
One of my users today presented me with a minor irritant. Here's what happens:
1. User clicks a link in the table on phones.php
2. This opens phoneline.php which is a page that allows editing of a record
3. User clicks save on phoneline.php which returns to phones.php
4. User is dismayed to find that they are no longer on page 4 of phones.php (using the DataTable pagination functionality) and bugs me about it.

My question: Is there a way to save the state of the DataTable on a page (in a cookie perhaps?!) so that when returning to that same page, the DataTable is re-presented in the same state it was before leaving the page? IF the cookie had a very short expiry (say 5 minutes - more than enough time to edit a phoneline record).

Down the road, I'd like to convert my system so that the phoneline.php page opens via AJAX in the same page, thus rendering this discussion moot, but for now, my hands are tied.

Replies

  • allanallan Posts: 61,653Questions: 1Answers: 10,094 Site admin
    Sounds like the prefect situation for bStateSave - http://datatables.net/usage#bStateSave . This will save the table state such as page, filtering, sorting etc - so your user will return to exactly where they were. And even better you can se your cookie duration using iCookieDuration (it's in seconds): http://datatables.net/usage#iCookieDuration :-)

    Hope that helps,
    Allan
  • brilangbrilang Posts: 22Questions: 2Answers: 1
    OK. How did I miss that.
    When was this feature added?
  • brilangbrilang Posts: 22Questions: 2Answers: 1
    I see it now. I just checked the version I'm using (1.4.1)
    And then I checked the change history on the download page http://datatables.net/download
    and noticed this in the 1.4.2 changes: "Fixed: State saving javascript error"

    So that's why it's not working. :)
  • allanallan Posts: 61,653Questions: 1Answers: 10,094 Site admin
    Ah ha - that would do it :-). It was introduced in the 1.4 beta series, and then promptly broken in 1.4.0 final... Should be rock solid now though (crossing fingers).

    Regards,
    Allan
  • brilangbrilang Posts: 22Questions: 2Answers: 1
    Seems to be. I've replaced the plug in and it's working so far... :)
    Thanks for your prompt responses.
This discussion has been closed.