bDeferRender and fnRowCallback
bDeferRender and fnRowCallback
dorothyjjohnson
Posts: 8Questions: 0Answers: 0
I have a table that assigns colors to cells based on the content. It works well without bDeferRender, but with bDeferRender when the table is sorted on that column the coloring is lost. Without bDeferRender the table is much slower to load in IE. Any suggestions?
[code]
var oTable = $('.dataTable').dataTable({
"sAjaxSource": '../include/intage_ajax.html',
"bJQueryUI": true,
"sDom": 'rt<"F"ip<"clear">T>',
"bDeferRender": true,
"sScrollY": '550px',
"sPaginationType": "full_numbers",
"bScrollCollapse": true,
"oTableTools": $.planning.oTableTools,
"iDisplayLength": 25,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var count = aData[2];
var class_name = 'green-bg';
if (count > 150) {
class_name = 'red-bg';
} else if (count > 90) {
class_name = 'yellow-bg';
}
// Remove column sorting background color.
$('td:eq(2)', nRow).removeClass('sorting_1');
$('td:eq(2)', nRow).removeClass('sorting_2');
$('td:eq(2)', nRow).removeClass('sorting_3');
$('td:eq(2)', nRow).addClass(class_name);
return nRow;
}
});
[/code]
[code]
var oTable = $('.dataTable').dataTable({
"sAjaxSource": '../include/intage_ajax.html',
"bJQueryUI": true,
"sDom": 'rt<"F"ip<"clear">T>',
"bDeferRender": true,
"sScrollY": '550px',
"sPaginationType": "full_numbers",
"bScrollCollapse": true,
"oTableTools": $.planning.oTableTools,
"iDisplayLength": 25,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var count = aData[2];
var class_name = 'green-bg';
if (count > 150) {
class_name = 'red-bg';
} else if (count > 90) {
class_name = 'yellow-bg';
}
// Remove column sorting background color.
$('td:eq(2)', nRow).removeClass('sorting_1');
$('td:eq(2)', nRow).removeClass('sorting_2');
$('td:eq(2)', nRow).removeClass('sorting_3');
$('td:eq(2)', nRow).addClass(class_name);
return nRow;
}
});
[/code]
This discussion has been closed.
Replies
Allan
If you sort on Platforms the colors disappear, any other column they come back. If you remove bDeferRender you can sort on platforms and the colors stay. Thank you again for taking a look.
[code]
tr.odd.gradeA td.sorting_1 {
background-color: #C4FFC4;
}
[/code]
Just remove that from the demo CSS file and it should work just fine.
Allan
Just out of curiosity, isn't that what $('td:eq(2)', nRow).removeClass('sorting_1'); is suppose to do?
I think I'll write an article about the sequence of the callbacks on a draw at some point - thanks for the suggestion :-).
Allan