fnRowCallback with if cell contains (sub-)string?

fnRowCallback with if cell contains (sub-)string?

VanillaVanilla Posts: 5Questions: 0Answers: 0
edited December 2013 in General
How can I add a CSS class if a cell contains a string?
I want to the functions to be applied to all rows that contain the string 'oo' (e.g. foo)

I have tried this, but it doesn't work:

[code]
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
$test = "aData['Name']";
if (strpos($test,'oo') !== false) {
$(nRow).addClass('new');
}
return nRow;
}
[/code]

Replies

  • VanillaVanilla Posts: 5Questions: 0Answers: 0
    Got it working with this:

    [code]
    "fnRowCallback": function(nRow, aData) {
    var test = aData['Name']
    if (test.indexOf("oo") != -1) {
    $(nRow).addClass('new');
    }
    return nRow;
    }
    [/code]
This discussion has been closed.