fnRowCallback with if cell contains (sub-)string?
fnRowCallback with if cell contains (sub-)string?
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]
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]
This discussion has been closed.
Replies
[code]
"fnRowCallback": function(nRow, aData) {
var test = aData['Name']
if (test.indexOf("oo") != -1) {
$(nRow).addClass('new');
}
return nRow;
}
[/code]