[Solved] Add Style and/or Class option to GridHighlightedCellDescriptor

0 Answers 13 Views
Grid
Jerome
Top achievements
Rank 1
Jerome asked on 02 Jun 2026, 08:43 PM

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.

Dimo
Telerik team
commented on 03 Jun 2026, 06:10 AM

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?

Jerome
Top achievements
Rank 1
commented on 03 Jun 2026, 03:41 PM

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.
Dimo
Telerik team
commented on 04 Jun 2026, 01:57 PM

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:

  • We normally don't expose multiple ways to achieve the same result.
  • Users can highlight Grid cells through AI prompts and this was one of the main reasons to implement the feature. Users may choose to highlight various rows and cells for various reasons. Thus, custom styles may not be applicable and users may even be not aware of the existing options. I can't think of an existing similar approach in Telerik UI for Blazor where we combine a built-in feature like selection or highlighting with custom visualization.
  • The built-in highlight styles are designed to integrate with the built-in selection styles in case they are used together. Using custom styles may cause UX issues like difficulty to distinguish the two features.

Of course, if other customers request the same enhancement, we will reconsider.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Jerome
Top achievements
Rank 1
Share this question
or