Skip to content Skip to sidebar Skip to footer

Color Dgrid Cell Based On Cell Value

I've got a dgrid and I'm trying to set the cell background color based on the value of the cell using a formatter function and css. The dgrid is located within a div with ID UnMark

Solution 1:

Generally, the simplest way to do this would be to use renderCell, which gives you direct access to the cell:

Priority: {
    label: "Priority",
    renderCell: function (object, value, cell) {
        cell.className += " " + value;
        returndocument.createTextNode(value);
    }
}

Note that renderCell can return a node to be placed within the cell. I use createTextNode rather than just setting innerHTML since the latter would be potentially susceptible to HTML injection from the data source.

Post a Comment for "Color Dgrid Cell Based On Cell Value"