Attempting to use deferred rendering, but all rows being rendered on initialization

Attempting to use deferred rendering, but all rows being rendered on initialization

jkishjkish Posts: 1Questions: 0Answers: 0
edited October 2012 in General
I'm using Datatables 1.9.4 and looking for a speed improvement via deferred rendering.

I have bDeferRender: true, but I see my fnRender called for each row of each column for which it is defined during the initialization below even though all rows are not visible.

Here is the Datatable init code. I've tried commenting out many of these settings, but still get the same results.

[code]
table = $('#my-table').dataTable({
"aoColumns": [
{ "sWidth": "15%", "sType": "string"},
{ "sType": "string"},
{
"bSortable": false,
"bSearchable": false,
"sWidth": "15px",
"fnRender": function (oObj) {
return 'bunch of stuff';
}
},
{
"bSortable": false,
"bSearchable": false,
"sWidth": "15px",
"fnRender": function (oObj) {
return 'bunch of stuff';
}
},
{ "bSortable": false, "bSearchable": false, "bVisible": false },
{ "bSortable": false, "bSearchable": false, "bVisible": false },
{ "bSortable": false, "bSearchable": false, "bVisible": false }
],
"aaData": tableData,
"bAutoWidth": false,
"aaSorting": [[1, "asc"]],
"sScrollY": "11em",
"sScrollX": "100%",
"bPaginate": false,
"bScrollCollapse": true,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"sDom": "lrtip",
"bDeferRender": true
"oLanguage": {
"sZeroRecords": PM.resource.tableEmpty
},
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
$(nRow).attr('id', 'row-' + aData[6]);
return nRow;
}
});
[/code]
});

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Just because fnRender is being called doesn't mean that the rows are actually being created. Since fnRender result in the case above is used not only for display but also sorting and filtering fnRender _must_ be called for all rows before the table can be displayed (since there is an initial sort and filter applied).

    The other thing is that you've disabled pagination, so all rows must be drawn - thereby making the deferred rendering irrelevant!

    Allan
This discussion has been closed.