fnRowCallback in combination with dynamically showing/hiding columns
fnRowCallback in combination with dynamically showing/hiding columns
I'm currently using fnRowCallback to set a low contrast on "empty" cells that have values like "-" or "n/a". This was working great with the following set up:
[code]
$("table").dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
for(var i = 0; i < aData.length; i++) {
if(aData[i] == "n/a") {
$("td:eq(" + i + ")", nRow).html("" + aData[i] + "");
}
}
}
});
[/code]
However, once I enabled dynamic showing/hiding of columns this causes problems. I have all of row data in hand, but I don't know inside that function what's visible and what's not and therefore can't update the proper cell. Is there a clean way of handling this other than retrieving the column visibility during each row call and then doing some index dancing (i.e. need to affect the 4th cell, columns 1,3,7,8 are hidden so therefore I really need to update the 2nd cell).
Here's a jsFiddle (http://jsfiddle.net/UBASU/1/). Notice how the n/a will move to Col 2 once the first column is hidden.
[code]
$("table").dataTable({
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
for(var i = 0; i < aData.length; i++) {
if(aData[i] == "n/a") {
$("td:eq(" + i + ")", nRow).html("" + aData[i] + "");
}
}
}
});
[/code]
However, once I enabled dynamic showing/hiding of columns this causes problems. I have all of row data in hand, but I don't know inside that function what's visible and what's not and therefore can't update the proper cell. Is there a clean way of handling this other than retrieving the column visibility during each row call and then doing some index dancing (i.e. need to affect the 4th cell, columns 1,3,7,8 are hidden so therefore I really need to update the 2nd cell).
Here's a jsFiddle (http://jsfiddle.net/UBASU/1/). Notice how the n/a will move to Col 2 once the first column is hidden.
This discussion has been closed.