'Update Method RowInserted Not Called On Submit for Blazorise DataGrid
I need to have all the CRUD methods be external. But there is something missing. What?
I set the UseInternalEditing=false, define RowInserting and the external method OnRowInserted is not reached.
Code
<DataGrid TItem="AppInstructor"
EditMode="Blazorise.DataGrid.DataGridEditMode.Inline"
Editable="true"
RowInserted="@OnRowInserted"
UseInternalEditing="false"
ShowValidationFeedback="true"
Data="@_instService.GetALL()">
<DataGridCommandColumn TItem="AppInstructor">
<SaveCommandTemplate>
<Button Color="Color.Primary" Clicked="@context.Clicked">Save</Button>
</SaveCommandTemplate>
<EditCommandTemplate>
<Button Color="Color.Primary" Clicked="@context.Clicked">Edit</Button>
</EditCommandTemplate>
</DataGridCommandColumn>
<DataGridColumn TItem="AppInstructor" Field="@nameof(AppInstructor.LastName)" Editable="true" Caption="First Name" Sortable="true">
</DataGridColumn>
<DataGridColumn TItem="AppInstructor" Field="@nameof(AppInstructor.LastName)" Editable="true" Caption="Last Name" Sortable="true">
</DataGridColumn>
Code section
@code {
private void OnRowInserted(SavedRowItem<AppInstructor,
Dictionary<string, object>> e)
{
...
}
Solution 1:[1]
You have to add PreventDefaultOnSubmit to have your custom click event trigger.
<SaveCommandTemplate>
<Button Type="ButtonType.Submit"
PreventDefaultOnSubmit
Color="Color.Primary"
Clicked="@context.Clicked">Save</Button>
</SaveCommandTemplate>
Then RowInserted="OnRowInserted" will be called.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ΩmegaMan |
