I'm using Angular slickgrid and I want to change the cell color if the value is present in that cell.
Note: I want the color only for the cell not the whole row.
Is there any best way to iterate over all the cells and set the color or any equivalent solution?
I have a requirement to show the different cell colors depending on the data. Red color if the data is coming from the server and not changed (not dirty). If the data is edited or added new row (dirty), the cell color would be blue. I have updated the question.
function renderCellWithColor(cellNode, row, dataContext, colDef) {
if (dataContext[colDef.field] != ""){
$(cellNode).addClass("requiredClass"))
}
}
I'm using this function using enableAsyncPostRender
. This does not work if I edit or add new row.
Use the option
cssClass
on the column definition or use a Custom Formatter returning an object following theFormatterResultObject
, see Wikis Custom Formatter - FormatterResultObject - Wiki and sample - Wiki, theFormatterResultObject
has the advantage of applying the CSS class to the cell container via the propertyaddClasses
and using the formatter object is the only way to get access to the cell container.