fnRowCallback blowing up under zero configuration conditions...
fnRowCallback blowing up under zero configuration conditions...
Good evening,
I'm a noob thinking fnRowCallback might be the answer to a project requirement. When I placed it in my code it blew things up so I started skinning things down to the basics to make sure it wasn't my code. I don't think it is. After all was removed I'm left with this:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$(document).ready(function() {
oTable = $('#mytable').dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
alert( 'DataTables has redrawn the row' );
}
});
});
Row Callback Test
Product
Price
Current Row Callback
0.05
Working Row Callback
Perhaps Priceless
I'm a noob thinking fnRowCallback might be the answer to a project requirement. When I placed it in my code it blew things up so I started skinning things down to the basics to make sure it wasn't my code. I don't think it is. After all was removed I'm left with this:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$(document).ready(function() {
oTable = $('#mytable').dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
alert( 'DataTables has redrawn the row' );
}
});
});
Row Callback Test
Product
Price
Current Row Callback
0.05
Working Row Callback
Perhaps Priceless
This discussion has been closed.
Replies
The fnRowCallback needs to return a row. In this case, you want to just return nRow right away. (Later on you can modify it first as needed).
Change the following:
[code]
$(document).ready(function() {
oTable = $('#mytable').dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
alert( 'DataTables has redrawn the row' );
}
});
});
[/code]
to
[code]
$(document).ready(function() {
oTable = $('#mytable').dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
return nRow; //alert( 'DataTables has redrawn the row' );
}
});
});
[/code]
This will definitely get rid of the first error, but I'm not 100% sure about the second.
See here for further documentation on the fnRowCallback function: http://datatables.net/usage/callbacks#fnRowCallback
Hope this helps.
That was it. Thank you very much for helping!
Live and learn!