How to change colour of row depending on 1 columns data?

Hi, I'm trying to change the whole row background colour to a certain colour if a certain condition is met.
My conditions are:
If status is text "Failure", the whole row should turn red colour background with white text or something.
else, do nothing.

Here is what I've tried so far:

<RadzenGrid @ref="serversGrid" AllowFiltering="true" FilterCaseSensitivity="Radzen.FilterCaseSensitivity.CaseInsensitive"
                AllowPaging="true" AllowSorting="true" Data="@serverData" TItem="ServerDTO"
                ColumnWidth="200px" RowUpdate="@OnUpdateRow" PageSize="10" RowRender="@RowRender">
<Columns>
<RadzenGridColumn TItem="ServerDTO" Property="Status" Title="Status">
                <EditTemplate Context="server">
                    <RadzenDropDown @bind-Value="server.Status" Data="@statusList" Style="width:100%" />
                </EditTemplate>
            </RadzenGridColumn>
</Columns>

As you can see I have my RowRender in the grid, now I have this as well:

void RowRender(RowRenderEventArgs<ServerDTO> args)
    {
        args.Attributes.Add("style", $"background-color: {(args.Data.Status.Equals("Failure") ? "Red" : "White")};");
    }

Im doing this and its not working? Is my syntax incorrect? I'm getting no errors when I run but its not turning red when the value of status is failure

Any help is appreciate thank you!

Try searching the forum before posting your questions. There are multiple threads related to this:

1 Like

Hi thanks for that,

If I have multiple conditions like if active = green, if failure = red, if anything inbetween yellow, how would I go about implementing this logic?

You can use if statement

You can use the exact same code as before - just handle CellRender as mentioned in the linked thread.

thank you! working like a charm :*