Set background color based on value in other cell
Set background color based on value in other cell
Mirrh
Posts: 2Questions: 0Answers: 0
Hi,
I really love this DataTables,
Please help me. How to set background color based on value of other cell?
[code]
"aoColumnDefs": [
{
"aTargets":[2],
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
if(sData == 'Value')
{
// How to set background color of other cell like
// "aTargets":[1] $(nTd).css('background-color', 'blue');
$(nTd).css('background-color', 'blue');
}
},
}
]
[/code]
Thank you in advance
I really love this DataTables,
Please help me. How to set background color based on value of other cell?
[code]
"aoColumnDefs": [
{
"aTargets":[2],
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
if(sData == 'Value')
{
// How to set background color of other cell like
// "aTargets":[1] $(nTd).css('background-color', 'blue');
$(nTd).css('background-color', 'blue');
}
},
}
]
[/code]
Thank you in advance
This discussion has been closed.
Replies
I found the way as below,
[code]
"aoColumnDefs": [
{
"aTargets": [2],
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
var lociMatch = oData[21];
if (lociMatch[1] == "1") {
$(nTd).css('background-color', '#FFFACD');
}
}
}]
[/code]
I just want to thank you Allan and people who made this wonderful tool.
Thank you.