Does anyone know how to set the color of a full column in Grid? I’d like to alternate colors in some columns so the differences stand out as the user scrolls through the grid.
I find the Grid ‘rows’ pretty easy to color. Columns, not so much. However, with that said, I use the following approach to color my columns. Example snippet was lifted from the DHX support site:
https://snippet.dhtmlx.com/6xjqbwag
Here is the example code (again, from the DHX site):
const grid = new dhx.Grid(“grid_container”, {
columns: [
{
id: “population”, header: [{ text: “Population” }],
// marks specified cells in a column
mark: function (cell, data, row, col) {
return cell > 100000000 ? “my_custom_mark” : “”
}
},
{
id: “density”, header: [{ text: “Density (P/Km²)” }],
// marks all cells in a column
mark: function (cell, data) { return “total_col”; }
},
],
data: dataset
});
Thank you for the example and the resource! That was exactly what I was looking for.