I like the HighlightedCells property on Grids. Is it possible to specify a style option for each item in the list? I would much prefer this over the OnCellRender event.
Then I would be able to specify that GridHighlightCellDescriptors with ColumnField of X should be Red, and ColumnFields of Y should be Blue.
Hi Jerome,
The Grid column OnCellRender event is how one styles cells conditionally and per column. Why do you need an alternative approach? Also, can you explain why do you need different highlight styles for different columns?
Is the "HighlightedCells" property not already an alternative to the OnCellRender event? For me at least, OnCellRender is clunky compared to the HighlightedCells method.
I am using the grid as a "Helper" report for another task. The goal is to be able to show users all data, and highlight key info.
Below is an example of how I'd like to use the HighlightedCells property.
.razor file
<TelerikGrid Data="Data" HighlightedCells="HighlightedCells" ... />.cs file
protected override async Task OnInitializedAsync() { HighlightCells(); } void HighlightCells() { var warnings = Data.Where(s => s.WarnFlag).Select(s => new GridHighlightedCellDescriptor { ColumnField = "Sales", DataItem = s, SuggestingClassProperty="MyWarningStyle"}); var success = Data.Where(s => s.Success).Select(s => new GridHighlightedCellDescriptor { ColumnField = "Sales", DataItem = s, SuggestingClassProperty="MySuccessStyle"}); var info = Data.Where(s => s.Description.Contains("REVIEW").Select(s => new GridHighlightedCellDescriptor {ColumnField = "Item", DataItem = s, SuggestingClassProperty="MyInfoStyle"}); HighlightedCells = warnings.Concat(success).Concat(info).ToList(); }I am currently using this method to highlight cells in my grid, and just getting by with the standard highlighting. I've found it easier to implement then adding cell render events to each column.
Hi Jerome,
Thanks for the insights. I confirm that the built-in features designed to handle your use case are the OnCellRender event and the column Template. The event is more suitable if you want to style the whole cell, while the template affects the cell content only.
There are a few concerns with custom styles for highlighted cells:
Of course, if other customers request the same enhancement, we will reconsider.