API to get numbers from dataTables_info ?

API to get numbers from dataTables_info ?

louis1984louis1984 Posts: 2Questions: 1Answers: 0

Hi there,
I'm just starting to use this amazing library and I really enjoy it, so prior to all : thanks a lot, wonderful job !
My question is how to get the numbers from the small text displayed under the table that says for example :
"Showing 1 to 10 of 26 entries (filtered from 34 total entries)".
Is there a smart way to do it ?
Thanks !

Louis

Answers

  • louis1984louis1984 Posts: 2Questions: 1Answers: 0

    by the way, the only numbers I want to get are :
    - number of filtered entries
    - total entries
    thanks

  • anaganag Posts: 48Questions: 2Answers: 7
    edited June 2014

    You can retrieve those numbers using the infoCallback function, an example is below which outputs the values to the console. As you filter the table you'll see in the console the end number updates.

    http://datatables.net/reference/option/infoCallback

    infoCallback: function( settings, start, end, max, total, pre ) {
    console.log(start);
    console.log(end);
    console.log(settings);
    return start +" to "+ end;
     }
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited June 2014

    Hi Louis,

    If you just want the numbers, you can use the DataTables API method page.info() to get that information. It returns an object whose properties describe the paging state of the table. You can use the page event, or the infoCallback that @anag mentions if you want to update your external controls whenever the paging information changes.

    Regards,
    Allan

This discussion has been closed.