Custom css for each cell

Custom css for each cell

robertino_salemirobertino_salemi Posts: 13Questions: 0Answers: 0
edited April 2014 in General
Hi,
thank you for your plugin.

I want apply a custom class css to each cell, so i wrote:
[code]
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
for (var i = 0; i < nRow.offsetTop; i++) { <-- offsetTop error?!?
switch (aData[i]) {
case "Y":
var new_class = "UnitChargeStatusYes";
var new_text = "Y";
break;
case "N":
var new_text = "";
break;
case "M":
var new_class = "UnitChargeStatusMaybe";
var new_text = "M";
break;
}
$('td:eq(i)', nRow).addClass(new_class); <-- Error!?!
}
},
[/code]

It's not works! :(

Why?

Thanks.

Replies

  • robertino_salemirobertino_salemi Posts: 13Questions: 0Answers: 0
    This is my solution:

    [code]
    "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
    for (i in aData) {
    if (!!aData[i]) {
    switch (aData[i]) {
    case "Y":
    var new_class = "UnitChargeStatusYes";
    var new_text = "";
    break;
    case "N":
    var new_class = "UnitChargeStatusNo";
    var new_text = "";
    break;
    case "M":
    var new_class = "UnitChargeStatusMaybe";
    var new_text = "";
    break;
    }

    $('td:eq(' + i + ')', nRow).html(new_text);
    $('td:eq(' + i + ')', nRow).addClass(new_class);
    }
    }
    }
    [/code]
This discussion has been closed.