jQuery数据表 - 在表上显示行数

azz*_*idz 2 jquery datatables

我在我的视图上有一个jQuery数据表,我正在使用分页在一个页面上显示10,20,50或100行.我想在桌子上显示某个行数.因此,如果我说每页显示10行显示的400行将显示400行中的1 - 10行.我似乎无法找到如何做到这一点.

解:

(当数据加载到表中时,此事件会激活,我可以获取数据长度并将其显示在我想要的地方)

table = $('#MyDataTable').dataTable({
            fnDrawCallback": function (oSettings, json) {
                console.log('Total row count on load - ', table.fnGetData().length);
            },
Run Code Online (Sandbox Code Playgroud)

Gyr*_*com 5

你需要设置infotrue.

$(document).ready(function() {
    $('#example').DataTable( {
        'info': true
    } );
} );
Run Code Online (Sandbox Code Playgroud)

此外,如果您已定义dom选项,请确保i字符串中存在字符,例如:

$(document).ready(function() {
    $('#example').DataTable( {
        'dom': 'lfrtip',
        'info': true
    } );
} );
Run Code Online (Sandbox Code Playgroud)