Yuri
Yuri

Reputation: 3284

Datatables missing last row

I have a problem when I try to show "All" records in my Datatable. I use the Pipelining function with my Datatables and (except for the pipeline) this is my JS:

var dTable = $('#myTable').DataTable( {
    "processing": true,
    "serverSide": true,
    "bSortCellsTop": true,
    "autoWidth": false,
    "aLengthMenu": [
        [25, 50, 100, 500, -1],
        [25, 50, 100, 500, "All"]
    ],
    "iDisplayLength": 50,
    "order": [[ 10, "asc" ]],
    "dom": '<"top"<"dd-area">flp<"button-area">>rt<"bottom"flpi><"clear">',
    "ajax": $.fn.dataTable.pipeline( {
        url: '_handler.php?action='+action+'&cms='+curr_cms
    } ),
    "columns": [
        /* columns defined here */
    ],
    "columnDefs": [
        {
            "targets": ['_all'],
            "createdCell": function (td, cellData, rowData, row, col) {
                $(td).attr('title', $titles[col]);
            }
        }
    ],
    "search": "Search:",
    "zeroRecords": "No record found",
    "fnInitComplete" : function(oSettings, json) {
        /* code here */
    },
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
        /* code here */
    }
} );

With "All" selected in the length menu, I get Showing 1 to 337 of 338 entries.

I already checked my remote source and all 338 records are correctly sent, but the very last item of the 'data' array isn't shown in the frontend table.

If I set bPaginate: false all entries are correctly shown.

Any idea?

Upvotes: 0

Views: 918

Answers (1)

Aymeric Brudey
Aymeric Brudey

Reputation: 46

if you use the example code Pipelining of Datatable, they have an error into this. You need to modify this lines

if ( requestLength >= -1 ) {
    json.data.splice( requestLength, json.data.length );
}

and remove the equal

if ( requestLength > -1 ) {
    json.data.splice( requestLength, json.data.length );
}

Upvotes: 2

Related Questions