Change styling based on sData and value of cell based on oData.a
Change styling based on sData and value of cell based on oData.a
Using DataTables, I post data through an object. I am trying to customize a cell in a DataTable based on 2 different criteria.
To change the CSS I use the ''''fnCreatedCell''': feature. Here I change the css based on the ''''sData'''' value.
I would like to add a criteria, however, and ask to change the cell value if (oData.value == true) is met, but then maintaining the set CSS I have set in the '''fnCreatedCell''''.
I am tryng to avoid in writing extra code outside the dataTable function to determine this before making the table~~~~.
here is my code to show what I want to do,
$(nTd).css('border-left', '0.2vw solid #333333')
if (sData == readyToPlay) {
$(nTd).css('background-color', '#71da71')
$(nTd).css('width', '60px')
} else if (sData == playersCurrentlyPlaying ) {
$(nTd).css('background-color', '#ffffb3')
} else if (sData == playersUnavailable ) {
$(nTd).css('background-color', '#ff8080')
}
AND
if(oData.priority == true){
sData = "priority match"
$(nTd).css('background-color', '#ffffb3')
}
Answers
I may have something that might help. I have a fiddle that shows updating background colors using the fnRowCallBack.
jsfiddle.net/lecleard/q3wtrn3r/