keeping pagination results

keeping pagination results

loadbrainloadbrain Posts: 18Questions: 0Answers: 0
edited July 2009 in General
Another thing I can not figure out.
I have a table showing abou 130 entries, 10 per page.
Now i.e I am on page 3, update an entry and after closing dialog, I am landing on page 1 showing the first 10 entries.
I would like to stay on page 3.
I have the iDisplayStart and it is showing the right value, but how to make the display show me entries 30 - 40?

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi loadbrain,

    The reason that it jumps back to page one is because of the resort that occurs once the data has been updated. This resort is required because the updated data might need to be repositioned in the table. However, you can overrule this by passing false as the fourth parameter, assuming you are using fnUpdate ( http://datatables.net/api#fnUpdate ).

    Other options include taking a note of the start point before you do the update, and then set it back to that value once the update is complete.

    Regards,
    Allan
  • loadbrainloadbrain Posts: 18Questions: 0Answers: 0
    Well I use this fnAjaxReload function, not fnUpdate....
    I know the start point but how can I set it back?
  • loadbrainloadbrain Posts: 18Questions: 0Answers: 0
    I try to do something like this in my function:

    oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(20, 30);

    ....
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi loadbrain,

    I'd suggest not doing that :-) It could make some very weird things happen :-)

    I presume that you are getting the start point by using var start = oSettings._iDisplayStart;. In which case why not just do oSettings._iDisplayStart = start after the update and then call fnDraw().

    Using fnAjaxReload it is not surprising that it takes you back to page 1 since it erases the old data and then displays the new data. As such it had no idea what has gone before, and it's up to the developer to implement whatever interaction they want for when this happens (for example some people use fnAjaxReload to load completely different data - where you would want to start at the first row again).

    Allan
  • loadbrainloadbrain Posts: 18Questions: 0Answers: 0
    Ok, I got it!

    Setting
    oSettings.iInitDisplayStart = oSettings.iDisplayStart;
    in function fnReloadAjax as in http://www.datatables.net/plug-ins#api
    makes it working, after Ajax Reload, page stays on the 10 entries from before
This discussion has been closed.