advance pagination with script

advance pagination with script

wpswps Posts: 15Questions: 0Answers: 0
edited September 2009 in General
I am trying to advance/retreat the pagination (next or previous page) within a script. I have seen how custom pagination controls can be made creating a plug-in with the API, but this is not what I want to do. I simple want to advance or retreat the pagination when certain conditions are met within a script.

I have tried…

[code]
oSettings._iDisplayStart = newValue;
oTable.fnDraw();
[/code]

…but it does nothing. The only way I have gotten it to work is "clicking" the next/previous buttons virtually with jQuery's click() event…

[code]
$('.paginate_enabled_next').click();
[/code]

…but that seems like a hack. How can I make this work using DataTables' building in functions/features?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi wps,

    The reason that setting _iDisplayStart before calling fnDraw() is discussed here http://datatables.net/forums/comments.php?DiscussionID=607 and here http://datatables.net/forums/comments.php?DiscussionID=573 . There are ways around it the display being set back to the first page - and you might want to implement one of these, as required.

    There is also the option of invoking the click event on "oSettings.nNext" and oSettings.nPrevious" (two button paging only - a small modification would be needed for this in full_numbers) which is what I do in the unit tests.

    Basically it comes down to the fact that there isn't really an API function for "paging turning" - perhaps one for a plug-in... :-)

    Regards,
    Allan
This discussion has been closed.