Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  39] [ 1]  / answers: 1 / hits: 104535  / 9 Years ago, wed, may 20, 2015, 12:00:00

I am using a datatable for my application. How do I get the total count of the rows in the datatable onload? My code:



$(document).ready( function() {
$('#jobSearchResultTable').dataTable({
responsive: true,
scrollY: 500,
scrollCollapse: true,
jQueryUI: true,
aaSorting: []
});
)};


How to get the total count of rows in the datatable onload


More From » jquery

 Answers
63

Update for New Versions


table.data().count()

Reference:https://datatables.net/reference/api/count()


For older versions:


$(document).ready(function() {
//Initialize your table
var table = $('#jobSearchResultTable').dataTable();
//Get the total rows
alert(table.fnGetData().length);
});

Source: https://stackoverflow.com/questions/3238047/jquery-datatables-row-count-across-pages


Another method:


table.fnSettings().fnRecordsTotal();

see which one works for you


Source: http://datatables.net/forums/discussion/2278/how-to-get-number-of-rows/


[#66529] Monday, May 18, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taylert

Total Points: 627
Total Questions: 91
Total Answers: 108

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
taylert questions
;