5

I have a jQuery datatable on my view and i'm using pagination to display 10, 20, 50 or 100 rows on a single page. I would like to display somewhere on the table row count. So if i have say 400 rows displayed by 10 on each page message would be Showing 1 - 10 of 400 rows. I can't seem to find how to do it.

Solution:

(This event fires up when data is loaded into table, i can get data length and display it where ever i want)

table = $('#MyDataTable').dataTable({
            fnDrawCallback": function (oSettings, json) {
                console.log('Total row count on load - ', table.fnGetData().length);
            },
3
  • you want to show the message ` Showing 1 - 10 of 400 rows` in some other place in page , right ? Commented Aug 28, 2015 at 2:25
  • Yea, i had a problem since data comes with a little delay. I managed to find event that fires up when table is filled with data. it's table = $('#MyDataTable').dataTable({ //"fnDrawCallback": function (oSettings, json) { // //console.log('Total row count on load - ', table.fnGetData().length); //}, Commented Aug 28, 2015 at 8:30
  • it would help someone in future if post it as answer (as new post or as solution in your question itself) @azza idz Commented Aug 28, 2015 at 10:34

4 Answers 4

11

You need to set info to true.

$(document).ready(function() {
    $('#example').DataTable( {
        'info': true
    } );
} );

Also if you have defined dom option, make sure there is character i present in the string, for example:

$(document).ready(function() {
    $('#example').DataTable( {
        'dom': 'lfrtip',
        'info': true
    } );
} );
Sign up to request clarification or add additional context in comments.

Comments

1
$(function() {
  $("#example").DataTable({
    "dom": '<lfip><t><ip>',
    "info": true
  });
});

1 Comment

Please, add more details, to your answer, further explaining your code.
0

You're going to want to take a look at this example. Use the option paginationType: 'full_numbers'

Comments

0

Solution:

(This event fires up when data is loaded into table, i can get data length and display it where ever i want)

table = $('#MyDataTable').dataTable({
            fnDrawCallback": function (oSettings, json) {
                console.log('Total row count on load - ', table.fnGetData().length);
            },

1 Comment

Why down vote it if i may know? This will give correct row number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.