How to handle row selected changed event for a table using Blazor? I tried handling @onchange as well as @onselectionchange. The syntax for the table looks like this:
You can use Onclick in the row:
<tbody>
@foreach (var item in Forecasts)
{
<tr class="@item.Clase" @onclick="@(() => DoSomething(item))">
<td>@item.Date</td>
<td>@item.TemperatureC</td>
<td>@item.TemperatureF</td>
<td>@item.Summary</td>
</tr>
}
</tbody>
and create a Dosomething to receive the item
Your event binding doesn't work because the table
element does not emit change
events.
Instead, you could add an input element (for example a checkbox) inside your table rows. You can then handle row selection changes by adding your event binding to the input elements.
Read more on the HTMLElement change event in this article.