display page n instead of 1 after datatables initialized

display page n instead of 1 after datatables initialized

vcba79vcba79 Posts: 3Questions: 0Answers: 0
edited October 2009 in General
Hi, all

I have been using datatables for a while, it works great. Now I have a problem, I want to go to page n ( n > 1 ) after datatables initialized but I am not sure how to do it. I tried

oTable=$('#sells').dataTable( {
"bProcessing": true,
"iDisplayStart" : 30,
.
.
.

But this won't work, any help would be appreciated.

Thanks,

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Hi vcba79,

    Two options off the top of my head:

    1. Use the iDisplayStart option: http://datatables.net/usage/options#iDisplayStart - which will let you jump the display to a certain row. I've just tried this option and it should work fine in 1.5.2.

    2. You could make use of the fnPageChange() plug-in API function: http://datatables.net/plug-ins/api#fnPageChange . This will let you enter in an integer number and jump to that page.

    Regards,
    Allan
  • vcba79vcba79 Posts: 3Questions: 0Answers: 0
    Hi, Allan

    Thank you very much for your answer. I just tried option 1 with 1.5.2. It works. I must did something wrong. Does option 1 also work with 1.4? I got another 2 questions:

    1. Can I change iDisplayStart after datatable initialized? If yes, how can I do it, I don't have a clue.
    2. I use fnReloadAjax() a lot, iDisplayStart seems reset to 0 after this api called. Can I specify iDisplayStart after fnReloadAjax() called.

    Thanks,
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Hi vcba79,

    I'm afraid that iDisplayStart will not work with 1.4.x as it was introduced during the 1.5 beta cycle. Therefore I'd suggest upgrading to 1.5.2 - which should be fully compatible with 1.4.x.

    1. You could change iDisplayStart after initialisation, but it wouldn't make the blindest bit of different to anything, since iDisplayStart is only used at initialisation time :-). Are you looking to jump pages around? In which case you could use the API plug-in fnPageChange(): http://datatables.net/plug-ins/api#fnPageChange - or take some of the code from there and hack it around as you need.

    2. The reason for this is that DataTables is doing a resort when you reload that data from your Ajax source, and then this happens DataTables will jump the display back to the start (rather than having the end user in some random location in the new data). To get around this, have a look at this thread: http://datatables.net/forums/comments.php?DiscussionID=422

    Regards,
    Allan
This discussion has been closed.