[SOLVED] Customizing pagination (using two_numbers as a base)

[SOLVED] Customizing pagination (using two_numbers as a base)

intint Posts: 7Questions: 0Answers: 0
edited October 2012 in General
I'm trying to expand the two_numbers pagination to look roughly like:
[quote]
< Showing x-y of z >
[/quote]

But have run into some issues. Taking two_numbers from 1.9 as my base, I added the a span between the left and right arrows for the jQuery UI pagination controls in fnInit:

[code]
var sAppend = (!oSettings.bJUI) ?
''+oLang.sPrevious+''+
''+oLang.sNext+''
:
''+
''+
'';
$(nPaging).append( sAppend );
[/code]

I then made a few changes to fnUpdate, in particular adding a call that updates the span I added (see /* Info */) and changed the 'next' node call to nNode.nextSibling to nNode.nextSibling.nextSibling so it skips over my span (first line under /* Next page */):

[code]
/* Loop over each instance of the pager */
for ( var i=0, iLen=an.length ; i

Replies

  • renzosilvrenzosilv Posts: 11Questions: 0Answers: 0
    Is there a particular reason why you don't want to use the pagination type built in feature ?
    [code]"sPaginationType": "full_numbers",[/code]
    Do you just like the arrows better ?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    @int - Don't use _iRecordsTotal, but rather use fnRecordsDisplay(): http://datatables.net/docs/DataTables/1.9.4/DataTable.models.oSettings.html#fnRecordsDisplay .

    The internal variables for paging are a bit messy I know :-(. They need to be cleaned up at some point, but doing so will breaking existing code - such as your own now!

    Allan
  • intint Posts: 7Questions: 0Answers: 0
    @renzosilv - Client request! Normally no one cares about paging styles...but not today.

    @allan - Awesome, that worked perfectly. Thanks!

    The updated jsfiddle: http://jsfiddle.net/UWWqD/2/

    I also changed the line under /* Previous page */ from 'oSettings._iRecordsTotal' to 'oSettings._iDisplayStart', which fixed my issue with the prev control not being disabled correctly.
This discussion has been closed.