Soundar Rajan
Soundar Rajan

Reputation: 352

How to style an entire row in a Blazorise datagrid?

Is it possible to style an entire row in a Blazorise datagrid conditionally? for example, if Active == false, I want to gray out an entire row, using css

.inactive {
    text-color: gray;
}

I tried to use the RowStyling attribute but I am not sure how to use that (or if it can be used at all). If it can be used, I would like to pass the current TItem to the function. I can set the style at the row level () and use CSS to set global row colors.

Upvotes: 3

Views: 1480

Answers (1)

Dimitris Maragkos
Dimitris Maragkos

Reputation: 11392

Yes you can use RowStyling parameter. Example:

<DataGrid ...
          RowStyling="@OnRowStyling"

private void OnRowStyling(Employee employee, DataGridRowStyling styling)
{
    if (!employee.IsActive)
        styling.Class = "inactive";
}

Change Employee with your own model.

Upvotes: 4

Related Questions