GridColumn is getting disappear while clicking on Cancel button on Delete Conformation button

Hi Team,

I m using synfussion grid with inbuilt Insert,update and Delete function. 



whenever I m clicking on Cancel alert message, The Selected gridcolumn is disappering from grid control. It is getting visible after page refresh.

My source for binding grid is like this

 <SfGrid @ref="Gridview" DataSource="@GridData" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })"
                    AllowPaging="true">
                <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"
                                  Mode="EditMode.Dialog"></GridEditSettings>
                <GridEvents OnActionBegin="ActionBegin" TValue="Artist"></GridEvents>
                <GridColumns>
                    <GridColumn IsPrimaryKey="true" Field=@nameof(Artist.ArtistId) Visible="false"
                                HeaderText="ID #" TextAlign="@TextAlign.Left" Width="60">
                    </GridColumn>
                    <GridColumn Field=@nameof(Artist.Name) HeaderText="Artist Name"
                                ValidationRules="@(new ValidationRules{ Required=true})"
                                Width="150"></GridColumn>

                </GridColumns>
            </SfGrid>

---------------------------------------------------------------------------------------------
@code {

    private SfGrid<Artist> Gridview;
    public List<Artist> GridData { get; set; }
    protected override async Task OnInitializedAsync()
    {
        GridData = await client.GetFromJsonAsync<List<Artist>>("api/artist");
    }

    public async Task ActionBegin(ActionEventArgs<Artist> args)
    {
        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
        {
            var objArtist = new Artist();
            objArtist.ArtistId = args.Data.ArtistId;
            objArtist.Name = args.Data.Name;
            if (args.Data.ArtistId == 0)
            {
                await client.PostAsJsonAsync("api/artist", objArtist);
                Console.WriteLine("Saved successfully");
            }
            else
            {
                await client.PutAsJsonAsync("api/artist", objArtist);
                Console.WriteLine("Updated successfully");
            }

        }

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)
        {
            int id = args.Data.ArtistId;
            if (await js.InvokeAsync<bool>("confirm", $"Do you want to delete this Record?"))
            {
                var res = await client.DeleteAsync($"api/artist/{id}");
                Console.WriteLine("Deleted successfully");
            }
        }

    }

}

could you please suggest on work around fix ?


Regards
Chandradev


3 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team April 14, 2021 02:14 PM UTC

Hi Chandradev, 

Greetings from Syncfusion. 

We have validated your query with the provided details and we understood that you are facing problem while deleting a row with custom popup message(Showing prompt alert) using Javascript interop call in OnActionBegin event. So we suspect that the delete operation is occurred while performing the above action using JS interop call. 

For this we have already have default support for this requirement(show delete  confirmation dialog). You can show the delete confirmation dialog by using ShowDeleteConfirmDialog property of GridEditSettings

Reference

If we misunderstood your requirement, then could you please share more information about your requirement.  

Please let us know if you have any concerns. 

Regards, 
Rahul 


Marked as answer

CH chandradev April 14, 2021 04:22 PM UTC

Thanks Rahul. 


RN Rahul Narayanasamy Syncfusion Team April 15, 2021 04:05 AM UTC

Hi Chandradev, 

Thanks for the update. 

We are happy to hear that the provided solution was helpful to resolve the problem. 

Please get back to us if you have any concerns. 

Regards, 
Rahul 


Loader.
Up arrow icon