9

jQuery datatables - display the number of rows on the array

 2 years ago
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

advertisements

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

i am using below query and initialization code for jquery datatable ,but since the returned rows are more than 5000,browser becomes unresponsive ,i tried using server side option as well,but was not successful,can anyone guide me how to proceed thank

Add a border to jquery datatable excluding the search bar

this might be an easy question, but i need your help. How to add border to jquery datatable excluding the search bar? I tried using css but the border include the search bar. .table1{ border-width: 1px; border-style:solid; border-color: #A1A1A1; } $.

Force Gridview to display x number of rows, including blank lines

Is it possible to force gridview to display x number of rows even if the data is less than x rows? With the difference being made up with empty rows, of course. I found this page: http://aspdotnetcodebook.blogspot.ca/2008/03/how-to-force-force-x-numb

Multiple jQuery Datatables on the same page

I have two jQuery datatables on the same ascx page. I'm trying to insert a hyperlink into the toolbar div, which calls a link in the code behind, after the table has been rendered. Here's the code: var SDFtable = $('#tblSDF').dataTable( { "scrollY&qu

Using CSS and JQuery to display the total number of lists

CSS, JQuery, and just started to build my first site. I have a counter that counts the number of items in a list. The end result I'm working towards is to turn it into a notification badge/label and display it to the the user. It's functionality is e

Pass data from multiple rows of JQuery Datatables into the ASP.NET 5 / MVC 6 view using a submit all button

I have an ASP.NET 5 MVC application. I am using JQuery Datatables downloaded from Datatables.net for rendering my grid. I want to be able to select multiple records on the grid and through the click of one button to be able to update the status feild

jQuery Datatable - How to delete a row using the value of the cell

I want to search a cell in my JQuery datatable which has the content of var x and delete the row which contains the cell. I tried this: function deletedatarow(){ var x = "tzr"; $( "tr:contains('" + x + "')").fnDeleteRow(); };

jQuery DataTables - retrieves the page from a given row

I have a dataTable with hundreds of items with a fixed 50 iDisplayLength option. I need to be able to find what page a specific row is within the loaded nodes. All I've managed is to get the position, unfortunately that internal row position does not

Datatable displays the sum for all lines, instead of the lines currently displayed

I have created datatable with jQuery which has seven columns. But it has approx. 24 rows. Initially, First eight rows will be displayed. There is "show more" link at the end of table. If user click on that link then eight more rows will be displ

How to put any extension of a jquery datatables in the dt toolbar in a specific order?

I used the datatables jQuery plugin in my tables, and I add a button to the dt-toolbar. I want to add all extension of a datatables plugin like: Show and hide columns, filter, show number of rows in page. I tried this code : "sDom": "<'d

JQuery DataTables () returns the empty array, destroy () can not be called indefinite.

I have the following code: function clearAllCourses() { activeCourseIDs = [ 0 ]; UnloadStudents(); $('#Australia').show(); } function UnloadStudents() { var table = $('#studentDrillDownDataTable'); table.hide(); table.DataTable().destroy(); //table.c

JQuery datatable - Select the list in the column

I am currently pulling data in a jQuery datatable which is grand! But I am having an issue with the Role column. I am trying to inset a select list in that column which will have two options "admin" & "User" and whatever data is in

datatables initialize the array after the click of the button (ajax, jquery)

I have a problem loading datatables object. When I initialize and populate table on page load it works properly. THIS CODE BELOW WORKS PERFECT AT PAGE RELOAD. <script src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"><

jQuery DataTables hides the column without removing it from DOM

I need to hide a column from showing up in jquery datatables. When I hide the column using bVisible property it disappears from the DOM. I want to set display property of table cells of a column to none so that the values do not appear in the view bu

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK