1

I have problem with confirmation popup during deleting item. When I click "Delete" confirmation window is popup-ing more times than one, and I don't know why. And second question is how I can change text of that window? I tried This code but don't work:

columns: [
   ...,
{command: [{name: "destroy", text: "Delete Item", click: deleteItem}],
 title: " ", width: "100px"}
]

and function for delete:

function deleteItem(e) {
   var item = this.dataItem($(e.currentTarget).closest("tr"));
   if (confirm("delete item " + item.Name + " ?")) {
      var grid = $("grid").data("kendoGrid");
      grid.dataSource.remove(item);
      grid.dataSource.sync();
      grid.refresh();
   }
}

edited: second problem which I found is, after click update button some items from grid are removed

Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174

3 Answers3

0

Check the following sample and let me know if it helps:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/custom-delete-confirmation-dialog

knikolov
  • 1,650
  • 1
  • 12
  • 18
  • i'm forget for div with window id :) .. so delete works but i found issues with update ... after click update button some items are removed from grid or remove all items .. it's random – Denis Stephanov Jun 28 '16 at 11:50
  • my code is here https://jsfiddle.net/brg2eraq/ ... but not work becouse my service is only local – Denis Stephanov Jun 28 '16 at 12:23
0

probably you must try using following code before every other in the delete handler

e.preventDefault()

This will prevent the execution of the default window and will provide space for the confirm to popup.Thus, allowing just one window in front of you I hope this helps

0

The duplicate confirmation is due to you binding your command to the name "destroy" which is a built-in command provided by the grid. The command is firing, showing the built-in confirmation and then showing your confirmation. If you wish to handle the destroy method yourself simply rename the command to something other than "destroy" that is unique to you so that the default command event doesn't fire:

{command: [{name: "delete", text: "Delete Item", click: deleteItem}], title: " ", width: "100px"}

It appears you've got a few other issues in your deleteItem function as well. Try the following instead:

function deleteItem(e) {
   var item = this.dataItem($(e.target).closest("tr"));
   if (confirm("delete item " + item.Name + " ?")) {
      var grid = $("#grid").data("kendoGrid");
      grid.dataSource.remove(item);
      grid.dataSource.sync();
      grid.refresh();
   }
}

Notice I changed your code to use e.target rather than e.currentTarget and also modified your jQuery selector to look for #grid instead of grid assuming you're querying for an id and not a class.

See this snippet for a working example similar to what you're trying to do.

ramsey_tm
  • 792
  • 5
  • 7
  • ok, i repair code and try debug in browser, but i found this error https://ctrlv.cz/shots/2016/06/28/Zytu.png maybe this is reason why i have trouble with window ... do you have idea why couldn't initialize item? – Denis Stephanov Jun 28 '16 at 08:57