Editor: Render, CSS Issue
Editor: Render, CSS Issue
Trying to change the background color of a cell to the color I have in the database for a specific status. The issue is that it's working for the first row only, and all subsequent rows do not apply the color for it's row/cell.
Here's the column in my columns[] definition:
{
"data": "logan_jobs.jobNumber", "className": "nowrap",
"render": function (data, type, full, meta) {
var color = full.logan_status.displayColor;
$("td:eq(1)").css('background', color);
return data;
}
}
Note this definition is for the second column. In row one, the background of the second column changes appropriately to green, the status/status color of that jobNumber. In all subsequent rows, the color for column two does not change and is not being applied, according to the element inspector.
What am I missing?
This question has an accepted answers - jump to answer
Answers
You can't use jQuery / DOM methods in the
columns.rendermethod I'm afraid. The DOM is not guaranteed to be available for that cell when the method is called. The one to use isrowCallback. Make sure you also scope the jQuery selector to that specific row - e.g.$('td:eq(1)', tr )wheretris the row node passed into therowCallbackfunction.Allan
Totally worked. Thanks!!
Solution: