1

我需要让所有的 CRUD 方法都是外部的。但是缺少一些东西。什么?

我设置了UseInternalEditing=false, define并且没有达到RowInserting外部方法。OnRowInserted

代码
<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 {

private void OnRowInserted(SavedRowItem<AppInstructor,
                           Dictionary<string, object>> e)
{
   ...
}
4

1 回答 1

1

您必须添加PreventDefaultOnSubmit自定义点击事件触发器。

<SaveCommandTemplate>
    <Button Type="ButtonType.Submit" 
            PreventDefaultOnSubmit 
            Color="Color.Primary"
            Clicked="@context.Clicked">Save</Button>

</SaveCommandTemplate>

然后RowInserted="OnRowInserted"会被调用。

于 2022-02-08T16:15:13.297 回答