Format Pagination Info Display

Format Pagination Info Display

jakotheshadowsjakotheshadows Posts: 2Questions: 0Answers: 0
edited November 2013 in DataTables 1.9
I'm using server side processing, and one of the DB tables I'm pulling data from is very large, making counts slow. To that end, I use a "scaling" count where I just count the first displayed record plus try to count the next 1000 in the database since the table may range from very small to very large.

What I'd like to do with datatables is reformat the "Showing x through y of z entries" (without changing datatables code as this is a special case in a larger web app) and display instead "Showing x through y of at least z entries" instead. Where can I get the x, y, and z I need to rewrite the text in that element?

Replies

  • unruledboyunruledboy Posts: 4Questions: 0Answers: 0
    edited November 2013
    in "fnDrawCallback",

    $('#' + YOUR_DATATABLES_TABLE_ID + '_info').text('WHATEVER TEXT FOR THE PAGE INFO');
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited November 2013
    Use the oLanguage.sInfo ( http://datatables.net/ref#sInfo ) option to define a custom string for the information output box.

    Allan
  • jakotheshadowsjakotheshadows Posts: 2Questions: 0Answers: 0
    edited November 2013
    My actual question wasn't on how to change the string, it was on where to get the DATA to change the string with. Since if I just put in whatever static string in there I lose the critical data that makes the info useful in the first place. Edit: Ah I see you can use things like _START_, _END_, and _TOTAL_ using the oLoanguage.sInfo option. Continue reading if you're interested in my hacky way I figured out before Allan replied xD

    (where myTable is the variable I assigned my Datatables instance to)
    iDisplayStart: [code]myTable.fnSettings()._iDisplayStart[/code]
    iDisplayLength: [code]myTable.fnSettings()._iDisplayLength[/code]

    So, for example if I want to change the info string to omit the "total" I can do:
    [code]
    $('#' + tableID + '_info').text('Showing Entries ' +
    (myTable.fnSettings()._iDisplayStart + 1)
    + ' to ' +
    (myTable.fnSettings()._iDisplayStart +
    myTable.fnSettings()._iDisplayLength));
    [/code]

    I imagine iTotalRecords and iTotalDisplayRecords can be accessed in a similar fashion for omission or modification.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Oh I see - you can use fnInfoCallback which provides the information, or the fnPagingInfo plug-in ( http://datatables.net/plug-ins/api#fnPagingInfo ).

    DataTables 1.10 has a similar function built in ( `page.info()` ).

    Allan
This discussion has been closed.