为什么不会显示所有记录?

时间:2014-02-10 14:09:29

标签: jquery datatable datatables

我正在使用DataTables一切正常,除了所有记录都没有出现在输出中:

enter image description here

这是我的代码:

        oTable = $('#permissions').dataTable( {
            //"sScrollY" : "425px", # I added this
            "sAjaxSource": url,
            "bServerSide": true,
            //"sDom": "t",
            "sDom": "frtiS", # I added this
            //"sPaginationType": "bootstrap",
            "bProcessing" : false, 
            //"aoColumnDefs": [{ "bSortable": false, "aTargets": [ 2,3 ] }],
            "aoColumnDefs": [ {
              "aTargets": [ 1 ], "sWidth": "30px",
              "mRender": function ( data, type, full ) {
                return format_checkbox('admin', data, full);}
            },{
              "aTargets": [ 2 ], "sWidth": "30px",
              "mRender": function ( data, type, full ) {
                return format_checkbox('consignment', data, full);}
            },{
              "aTargets": [ 3 ], "sWidth": "30px",
              "mRender": function ( data, type, full ) {
                return format_checkbox('team', data, full);}
            },{
              "aTargets": [ 4 ], "sWidth": "30px",
              "mRender": function ( data, type, full ) {
                return format_checkbox('agent', data, full);}
            },{
              "aTargets": [ 5 ], "sWidth": "30px",
              "mRender": function ( data, type, full ) {
                return format_checkbox('report', data, full);}
            },{
              "aTargets": [ 6 ],
              "mRender": function ( data, type, full ) {
                return '<button data-orgid="'+data+'" class="btn btn-danger delbutton">Delete</button>';
              }
            } ],
            "bDeferRender": true,
            "bStateSave": true,            
            "fnDrawCallback": function( oSettings ) {
                $('.switch').bootstrapSwitch();
                $('.switch').on('switch-change', function (e, data) {
                    var ds = $(data.el)[0].dataset, value = data.value;
                    var ndata = {orgid:ds["orgid"]}
                    ndata[ds["permission"]] = value ? "on" : "off";
                    $.post(post_url, JSON.stringify(ndata)).done(function(data) {
                        oTable.fnStandingRedraw();
                    });                    
                });
                $('#permissions button').click(function(){
                    $.post(del_url, JSON.stringify(this.dataset["orgid"])).done(function(data) {
                        oTable.fnStandingRedraw();
                    });
                });

            }
        });

我对DataTables相对较新。这不是我的代码,因为我只是修复了这个错误...我不明白为什么它没有显示所有记录?我玩了一下......我尝试将bProcessing更改为true,但它仍无效。即使我使用滚动条,它也不会加载最后2条记录......

我觉得答案/解决方案很简单。 我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

这是因为默认页面大小为10。您可以通过设置iDisplayLength属性来更改它。

oTable = $('#permissions').dataTable( {
    "iDisplayLength": 50,
    // rest of your code...

如果你想完全禁用分页,我真的不建议,你可以使用它:

"bPaginate": false

答案 1 :(得分:1)

 oTable = $('#permissions').dataTable( {
     "iDisplayLength": 50,
     "bPaginate": false
 });