Alternative pagination question.....

Alternative pagination question.....

lostogrelostogre Posts: 14Questions: 0Answers: 0
edited June 2009 in Plug-ins
I am working on a plugin that will allow the user to programmatically select a page while in alternative pagination. I have first and last page functions based on the datatables internal code working, but the datatables source code for clicking on a numbered page/navigating to that page is eluding me. Could someone possibly shed some light on this?

lostogre

Replies

  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    Hi lostogre,

    The code for the two pagination methods that DataTables has by default are in the $.fn.dataTableExt.oPagination object, and the specific function you are looking for is oPagination.full_numbers.fnUpdate(). These two methods are effectively 'built-in plug-ins' since they use exactly the same method as any plug-in pagination methods.

    Inside this fnUpdate() function you will find the code which deals with the elements which have the event handlers for dealing with the paging.

    You might also be interested in my "Visual Event" bookmarklet ( http://www.sprymedia.co.uk/article/Visual+Event ) which shows you visually what code is attached to what elements as event handlers.

    Regards,
    Allan
  • atcatc Posts: 14Questions: 0Answers: 0
    Hi Allan,

    thanks for providing such a great tool and for supporting and developing it so actively. I've managed to do pretty well with customizing and adapting it thus far, so feel like I really ought to be able to figure this out for myself, but I'm stumped as to how to actually implement your four-button pagination plugin. Could you please help me out here? I've tried various approaches but I'm basically just shooting in the dark at this point...

    Thanks much,
    Alison
  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    HI Alison,

    It should be simply a case of putting the code provided for the plug-in into the document somewhere after you have included the DataTables script, and before you actually initialise DataTables. Also you need to set the paging type to 'four_button'. Is this what you have done?

    Regards,
    Allan
  • atcatc Posts: 14Questions: 0Answers: 0
    edited July 2009
    Allan,

    When I set it up that way, I get the error "oSettings.nPaginate is undefined" and the table doesn't load at all. If I comment out the line [code]"sPaginationType": "four_button",[/code] then it works fine. Also works fine if I used [code]"sPaginationType": "full_numbers",[/code].

    I realize this might not be enough information to figure out where my bug is hiding, and I expect I'll have more questions for you along the way, so I'm putting together a dev version of my page that I can show as an illustration (I'm making a site for a client who is very protective of their content). I probably won't be able to get it up until this evening, though.

    Best,
    Alison
  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    Hi Alison,

    The full numbers will certainly work as it is built into DataTables. And without an override then it will use the two buttons method. So the problem is certainly limited to the four_button method. I've just tried it here and I believe it does work. I think it probably will be easier to debug when you have a demo page available.

    Regards,
    Allan
This discussion has been closed.