I need a way to color a selected cell, e.g. if its value is greater than something. I know how to color an entire row in a table.
private string TblRowStyle(Planowanie thing, int index)
{
if (thing.tydzien == tydzien)
{
return $"background: #D3D3D3";
}
else
{
return "";
}
}
<MudTable T="Planowanie" Items="@planowanie" FixedHeader="true" Height="@(fixed_header ?"800px":"")" CustomHeader="true" CustomFooter="true" Dense="true" Hover="true" Bordered="true" Striped="true" Breakpoint="Breakpoint.Sm" MultiSelection="false" RowStyleFunc="@((item, idx) => TblRowStyle(item, idx))" >
is coloring the entire row in the table. However, I need to set the colour of text in the cell conditionally, when the value is greater than something else.
You can use the
Style
property on the theMudTd
.Here's how to do it inline.
And an example using a function to handle the logic.
MudBlazor snippet