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

Remove() function firing Destroy event after Drag & Drop

2 Answers 717 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 18 Feb 2015, 11:26 PM
I am able to add rows, delete rows, and update my Kendo Grid via the CRUD operations in my controller. The issue I am having is that whenever I use the following drag and drop function the "remove()" triggers the Destroy event in my controller which deletes the row that was inserted and this is not what I am looking to do. The delete button is located in a column and only when this button is clicked do I want to trigger the Destroy event. My grid is editable and fully functional besides this issue which I have already spent a good amount of time trying to troubleshoot. Any help or work around for this matter would be greatly appreciated.


 function onChange(e) {

        var grid = $("#DropGrid").data("kendoGrid");
        
        var oldIndex = e.oldIndex;
        var newIndex = e.newIndex;
        var data = grid.dataSource.data();
        var dataItem = grid.dataSource.getByUid(e.item.data("uid"));
        var numRows = grid.dataSource.view().length; //total # of rows

       grid.dataSource.remove(dataItem);  //  <--- This is the line triggering the Destroy event.

        grid.dataSource.insert(newIndex, dataItem);
}

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 20 Feb 2015, 11:04 AM
Hello,

Try using pushDestroy instead of remove. The latter marks the removed item as destroyed whereas the former doesn't.

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
James
Top achievements
Rank 1
answered on 25 Feb 2015, 10:45 PM
This functionality did not solve the problem and also caused multiple errors in the drag and drop functionality. I was able to write my own Destroy function as well as a custom ClientTemplate for the "delete" button to alleviate the issues I was having.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
James
Top achievements
Rank 1
Share this question
or