Column Command Destroy Button Issue

1 Answer 44 Views
Grid
Dharyl
Top achievements
Rank 1
Dharyl asked on 27 Dec 2023, 06:38 AM | edited on 27 Dec 2023, 06:41 AM

I have this grid with Edit and Destroy column command buttons. As I click the Delete/Destroy button it instantly calls the Destroy action without waiting for the delete confirmation. How can I solve this?

 

@(Html.Kendo().Grid<Models.ViewModel>()
        .Name("grid")
        .EnableCustomBinding(true)
        .Columns(columns =>
        {
            columns.Command(command =>
            {
                command.Edit();
                command.Destroy();
            }).Width(180);
            columns.Bound(p => p.Sorting).Width(100).Filterable(false);
            columns.Bound(p => p.Code).Width(200).Filterable(true);
            columns.Bound(p => p.Description).Filterable(true);
        })
        .ToolBar(toolbar =>
        {
            toolbar.Search();
        })
        .Editable(editable => editable.Mode(GridEditMode.PopUp).DisplayDeleteConfirmation(true))
        .Filterable()
        .Pageable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Events(events => events.Error("error_handler"))
            .Model(model => model.Id(p => p.Id))
            .Read("gridReadDataSource", "MyGrid")
            .Update("gridEditDataSource", "MyGrid")
            .Destroy("gridDeleteDataSource", "MyGrid")
        )
)
James
Top achievements
Rank 1
commented on 01 Jan 2024, 12:59 AM

have you tried removing .displaydeleteconfirmation(true)

I’ve encountered this on a couple of occasions with some older releases. The default is to provide a confirmation. I now only include this with false when i want to supress the confirmation.

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 03 Jan 2024, 09:11 AM

Hello Dharyl,

Thank you for the code snippet and the details provided.

In order to achieve the desired behavior, I would recommend using the approach from the following demo:

The source code can be found in the "View Source" tab of the demo above.

Give a try to the pointed approach and let me know if this achieves the desired result.

 

Kind Regards,
Anton Mironov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Tags
Grid
Asked by
Dharyl
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or