jquery datatables row count across pages

前端 未结 5 2031
礼貌的吻别
礼貌的吻别 2021-02-18 13:50

I\'m using the jQuery DataTables plug-in for my HTML table.

Is there a way to get the row count of the number of rows in my table across pages.

For example, if I

5条回答
  •  不思量自难忘°
    2021-02-18 14:22

    It looks like DataTables is removing the rows that aren't on the current page from the DOM, so you aren't going to be able to count them with a jQuery selector. You'll have to use the DataTables API, specifically the fnGetData function:

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

提交回复
热议问题