Blazor Server Side - SfGrid: How to Conditionally format row background

I want to higlight rows based on a value in specific column. 

How do I set row background color based on a property value?
Ideally I would contifionally set a css class on a row element.

2 Replies 1 reply marked as answer

LI Liero October 24, 2020 12:23 PM UTC

Ok, I found a solution. I needed to use RowDatabound event and call args.Row.AddClass();

Similarly, to apply conditional formatting to cells, I need to use :

<GridEvents TValue="Item" QueryCellInfo="CustomizeCell" />

        public void CustomizeCell(QueryCellInfoEventArgs<Item> args)
        {
            if (args.Column.Field == nameof(item.Id) && args.Data.Id < 10)
            {
                args.Cell.AddClass(new string[] { cellClass });
            }
        }

Marked as answer

JP Jeevakanth Palaniappan Syncfusion Team October 26, 2020 05:20 AM UTC

Hi Liero, 

Greetings from Syncfusion support.  

We are happy to here that you have resolved your queries on your own. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon