I have a Blazorise DataGrid working, now I want to add a button to edit the record on a different page/component (not inline or popup).
My raw starting grid markup:
<DataGrid TItem="Year" Data="@years" Sortable="true" PageSize="30" UseInternalEditing="false">
<DataGridCommandColumn TItem="Year">
<EditCommandTemplate>
<Button Color="Color.Primary" Clicked="@((e) => OnYearEdit(e))">Edit</Button>
</EditCommandTemplate>
</DataGridCommandColumn>
<DataGridColumn TItem="Year" Field="@nameof(Year.IsActive)" Caption="Active?"></DataGridColumn>
<DataGridColumn TItem="Year" Field="@nameof(Year.YearId)" Caption="ID"></DataGridColumn>
</DataGrid>
Then I want the event called when the button is clicked passing in either the id or year object:
void OnYearEdit(int yearId)
{
NavigationManager.NavigateTo("/yearedit/1");
}
How can I achieve that?