user384496
user384496

Reputation: 180

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)
{
   ...
}

Upvotes: 2

Views: 1084

Answers (1)

Kevin Bassa
Kevin Bassa

Reputation: 213

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.

Upvotes: 1

Related Questions