Can I show page info instead of record info for sInfo?

Can I show page info instead of record info for sInfo?

Simon79Simon79 Posts: 8Questions: 1Answers: 0
edited August 2013 in DataTables 1.9
Instead of displaying something like the following for sInfo:

"Showing 1 to 10 of 15 entries"

is it possible to just show something like:

"Showing page 1 of 2"

and exclude the filtering details, etc? All I want is for the current set of filtered data the page I'm on and the total number of pages.

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Actually, currently no - but I think that's a darn good idea. I'll integrate that into DataTables 1.10 as its a fairly simple change.

    You could use fnInfoCallback in 1.9- and the plug-in fnPagingInfo to achieve this, but I'll put it straight into the core for 1.10. I'll try to do this later on today.

    Allan
  • Simon79Simon79 Posts: 8Questions: 1Answers: 0
    Brilliant, I look forward to it. If there were couple more "variables" available for use in the oLanguage.sInfo* settings (CURRENTPAGE and TOTALPAGES?) that would be nice too. :)

    I'll have a look at the fnInfoCallback options.

    thanks!
  • Simon79Simon79 Posts: 8Questions: 1Answers: 0
    fnInfoCallback + fnPagingInfo works nicely too, thanks Alan.

    FYI for anyone who needs something like this, just add fnPagingInfo:

    [code]
    /* API method to get paging information */
    $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) {
    return {
    "iStart": oSettings._iDisplayStart,
    "iEnd": oSettings.fnDisplayEnd(),
    "iLength": oSettings._iDisplayLength,
    "iTotal": oSettings.fnRecordsTotal(),
    "iFilteredTotal": oSettings.fnRecordsDisplay(),
    "iPage": oSettings._iDisplayLength === -1 ?
    0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
    "iTotalPages": oSettings._iDisplayLength === -1 ?
    0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
    };
    };
    [/code]

    then use fnInfoCallback:

    [code]
    'fnInfoCallback': function (oSettings) {
    var pagingInfo = $.fn.dataTableExt.oApi.fnPagingInfo(oSettings);
    return 'Showing page ' + (pagingInfo.iPage + 1) + ' of ' + pagingInfo.iTotalPages;
    }
    [/code]
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    edited August 2013
    I've just added `_PAGE_` and `_PAGES_` options into DataTables 1.10 (which is currently pre-beta).

    Commit here: https://github.com/DataTables/DataTablesSrc/commit/04be76a

    And if you are feeling brave, the built source here: https://github.com/DataTables/DataTables/blob/1_10_wip/media/js/jquery.dataTables.js

    This means that in 1.10 you can do:

    [code]
    $('#example').dataTable( {
    language: {
    info: "Showing page _PAGE_ of _PAGES_"
    }
    } );
    [/code]

    Nice suggestion - thanks for this :-)

    Allan
This discussion has been closed.