jquery datatables row count across pages

前端 未结 5 2018
礼貌的吻别
礼貌的吻别 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:34

    SOLUTION

    For DataTables 1.10

    Use page.info() to retrieve information about the table as shown below.

    Property recordsTotal will hold total number of records in the table.

    var table = $('#example').DataTable({
        "initComplete": function(settings, json){ 
            var info = this.api().page.info();
            console.log('Total records', info.recordsTotal);
            console.log('Displayed records', info.recordsDisplay);
        }
    });
    

    DEMO

    See this jsFiddle for code and demonstration.

    NOTES

    This solution will work for both client-side and server-side processing modes as long as you use page.info() once data has been retrieved, for example in initComplete callback function.

提交回复
热议问题