Can I add a number (1000) to info _START_ ?

Can I add a number (1000) to info _START_ ?

jjiang5jjiang5 Posts: 14Questions: 4Answers: 1

Hi,

Can I add a number (1000) to START , I want START to start with 1001, for example.
$('#example').dataTable( {
"language": {
"info": "Showing START to END of TOTAL entries"
}
} );

Thanks
Jin

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Not with the language.info as that's a hardcoded value, but you can create your own to over-write what's there - something like this,

    Colin

  • jjiang5jjiang5 Posts: 14Questions: 4Answers: 1

    Colin,

    Thank you for your quick response. I will try.

    Jin

  • jjiang5jjiang5 Posts: 14Questions: 4Answers: 1

    Colin,

    Works.

    Thanks
    Jin

  • jjiang5jjiang5 Posts: 14Questions: 4Answers: 1
    edited November 2021

    Colin,

    Somehow below datatable info text displays empty , could you help?

    var table = $('#cfsEntryDetailDT').DataTable();
    $('#cfsEntryDetailDT').on('page.dt', function() {
      var info = table.page.info();
      $('#cfsEntryDetailDT_info').text('Showing ' + (info.start + 1000)*1 + ' to ' + (info.end + 1000)*1 + ' of ' + (info.recordsTotal + 1000)*1 + ' records');
    
    });
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,321Questions: 26Answers: 4,948

    I suspect the problem is the draw event comes after the page event so the -event draw event is updating the info element with whatever is in language.info. If you are doing what Colin's example shows the the empty text is overwriting your line 4 statement. Use the draw event as Colin shows.

    If this doesn't work for you please provide a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • jjiang5jjiang5 Posts: 14Questions: 4Answers: 1

    Kevin,

    Thanks for help.

    When I use draw, it works.

    Thanks
    Jin

Sign In or Register to comment.