jQuery datatables - display the number of rows on the array
source link: https://www.codesd.com/item/jquery-datatables-display-the-number-of-rows-on-the-array.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
jQuery datatables - display the number of rows on the array
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);
},
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
} );
} );
Related Articles
how to display more than 10000 rows in jquery datatable, because the browser does not respond if it exceeds the limit
Add a border to jquery datatable excluding the search bar
Force Gridview to display x number of rows, including blank lines
Multiple jQuery Datatables on the same page
Using CSS and JQuery to display the total number of lists
Pass data from multiple rows of JQuery Datatables into the ASP.NET 5 / MVC 6 view using a submit all button
jQuery Datatable - How to delete a row using the value of the cell
jQuery DataTables - retrieves the page from a given row
Datatable displays the sum for all lines, instead of the lines currently displayed
How to put any extension of a jquery datatables in the dt toolbar in a specific order?
JQuery DataTables () returns the empty array, destroy () can not be called indefinite.
JQuery datatable - Select the list in the column
datatables initialize the array after the click of the button (ajax, jquery)
jQuery DataTables hides the column without removing it from DOM
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK