Highlight Row of a MatTable
Is there a way to highlight a MatTableRow based on conditional values in the row? i.e. where @context.Prediction = @context.Result <MatTableRow>
</MatTableRow>
No, it's not possible. Internally in MatTable the TableRows (which is the class that holds the Selected property) are created by enumerating the items of the MatTable and rendering them according to the razor you put inside the MatTableRow parameter. The Selected property is only modified by the toggle from the onClick handler
@foreach (var item in ItemList)
{
<TableRow Class="@RowClass" AllowSelection="@AllowSelection">@MatTableRow(item)</TableRow>
}
@markiemarkus , Can this be closed?
Below work-around worked for me.
Add a custom component and capture the Cascading Parameter Table Row and set Selected property via a parameter binding.
Eg Container component:
@ChildContent
@code{
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public bool IsSelected
{
get => Row == null ? false : Row.Selected;
set
{
if (Row == null) return;
Row.Selected = value;
}
}
[CascadingParameter]
public TableRow Row { get; set; }
}