This is a migrated thread and some comments may be shown as answers.

Batch Delete of multiple rows confirmation

3 Answers 321 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MOTASH
Top achievements
Rank 1
MOTASH asked on 26 Apr 2018, 11:33 AM

Hello,

I need to keep the confirmation of row deletion,but would like to have it in batch

I have the grid in 'batch Editing Mode',and setting of selectable: "multiple row", so using the following code :

                EntityManageGrid.select().each(function () {

                    EntityManageGrid.removeRow($(this).closest("tr"));
                });

will result in a confirmation on each row,while this is a batch operation that should be confirmed once

Is there another method to be able to delete batch rows with single confirmation for the whole batch operation

Thanks in avance

Regards,

MOTASH

3 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 30 Apr 2018, 07:39 AM
Hi Motash,

You can delete the data items directly from the DataSource API to avoid the Grid built-in confirmation. In this case, you will need to show your own confirmation message:
$("#grid").on("click", ".k-grid-delete-custom", function(e){
  e.preventDefault();
  var grid = $("#grid").data("kendoGrid");
  var selectedRows = grid.select();
 
  if(confirm("Do you want to delete selected rows?")){
    $.each(selectedRows, function(){
      var row = $(this);
      var dataItem = grid.dataItem(row);
      grid.dataSource.remove(dataItem);
      grid.dataSource.sync();
    });
  }
});

Here is a Dojo example with this implementation:
https://dojo.telerik.com/uCErAdod

You can also check this article for an example on how to use the Kendo UI Window for a more customized look of the confirmation:
Customize Confirmation Window

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Peter
Top achievements
Rank 1
answered on 20 Nov 2019, 07:43 PM

Only removes 1 row then gives the following error, even in the Dojo:

kendo.all.js:6199 Uncaught TypeError: Cannot read property 'uid' of undefined
    at M (kendo.all.js:6199)
    at kendo.all.js:6624
    at init._eachItem (kendo.all.js:6794)
    at init.remove (kendo.all.js:6618)
    at HTMLTableRowElement.<anonymous> (result:74)
    at Function.each (jquery.min.js:2)
    at HTMLAnchorElement.<anonymous> (result:71)
    at HTMLDivElement.dispatch (jquery.min.js:3)
    at HTMLDivElement.r.handle (jquery.min.js:3)
M @ kendo.all.js:6199
(anonymous) @ kendo.all.js:6624
_eachItem @ kendo.all.js:6794
remove @ kendo.all.js:6618
(anonymous) @ result:74
each @ jquery.min.js:2
(anonymous) @ result:71
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3

0
Ivan Danchev
Telerik team
answered on 22 Nov 2019, 06:54 PM

Peter,

The Grid clears the selection when an item is removed, so avoid getting an exception, consider modifying the logic for removing rows, as demonstrated in this updated dojo example.

Regards,
Ivan Danchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
MOTASH
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Peter
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or