SfGrid OnActionComplete not called after Delete

I need to perform my CRUD using the events.

The OnActionComplete event is not called for the "Delete" RequestType after deletion of a record in the ActionBegin event.

Short experimental code snippet:


<SfGrid TValue="Stuff"
        DataSource="Items"
        Toolbar="@(new List<string>() {"Add","Search"})">
    <GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true" Mode="EditMode.Dialog" ShowDeleteConfirmDialog="true"></GridEditSettings>
    <GridEvents OnActionBegin="ActionBegin" OnActionComplete="ActionCompleted" TValue="Stuff"></GridEvents>
    <GridColumns>
        <GridColumn Field="@nameof(Stuff.Thing)"></GridColumn>

    <GridColumn HeaderText="Editing" Width="150">
        <GridCommandColumns>
            <GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-edit", CssClass = "e-flat" })"></GridCommandColumn>
            <GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-delete", CssClass = "e-flat" })"></GridCommandColumn>
            <GridCommandColumn Type="CommandButtonType.Save" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-update", CssClass = "e-flat" })"></GridCommandColumn>
            <GridCommandColumn Type="CommandButtonType.Cancel" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-cancel-icon", CssClass = "e-flat" })"></GridCommandColumn>
        </GridCommandColumns>
    </GridColumn>
    </GridColumns>
</SfGrid>

private async Task ActionBegin(ActionEventArgs<Stuff> obj)
    {
        if (obj.RequestType == Action.Delete)
        {
            await obj.Data.DeleteAsync();
        }
        if (obj.RequestType == Action.Save)
        {
            await obj.Data.SaveAsync();
        }
    }


    private async Task ActionCompleted(ActionEventArgs<Stuff> obj)
    {
        if(obj.RequestType is Action.Save or Action.Delete) // RequestType Delete is never called after the delete
            await LoadData();
    }


Is this by design or perhaps a bug?

I think it's a bug. Because why won't you call ActionCompleted after the "D" Even


1 Reply

RS Renjith Singh Rajendran Syncfusion Team January 18, 2022 12:00 PM UTC

Hi Daniel, 
 
Greetings from Syncfusion support. 
 
We could see that you have not enabled IsPrimaryKey property in your shared codes. We would like to inform you that CRUD operation in Grid will take place only based on the unique PrimaryKey column value. So IsPrimaryKey property must be enabled to any one of the unique valued column defined in grid. Only based on primary key value, the CRUD will be properly performed in Grid.  
 
Please refer the below documentation for more details, 
 
We have also prepared a sample in which during Delete OnActionComplete event will be triggered, based on your shared codes for your reference. 
 
Please get back to us if you have further queries.  
 
Regards, 
Renjith R 


Loader.
Up arrow icon