@(Html.Kendo().Window()
.Name("window")
.Title("Are you sure you want to delete this record?")
.Visible(false) //the window will not appear before its .open method is called
.Width(400)
.Height(200)
)
4. Customize the delete button. The biggest difference from the Grid's approach is handling the deletion from the TreeList's datasource using the removeRow method. Additionally, include the Window's Kendo UI Template:
//Initialize the Window Templatevar windowTemplate = kendo.template($("#windowTemplate").html());
functiononDelete(e) {
e.preventDefault(); //prevent page scroll resetvar tr = $(e.target).closest("tr"); //get the row for deletionvar data = this.dataItem(tr); //get the row data so it can be referred latervarwindow = $("#window").data("kendoWindow");
window.content(windowTemplate(data)); //send the row data object to the template and render itwindow.center().open();
$("#yesButton").click(function () {
var treelist = $("#treelist").data("kendoTreeList");
treelist.removeRow(tr);
window.close();
})
$("#noButton").click(function () {
window.close();
})
}
Please take a look at the attached sample which demonstrates the above, and let me know if you have any questions.
Regards,
Patrick Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Many thanks for your solution. I was able to get it to work without much effort, simply by copying your example. One thing that is missing from step 4 is:
var windowTemplate = kendo.template($("#windowTemplate").html());
I was getting a windowTemplate error, but was able to see what was different from the code in the zip file you included.
Once again - many thanks.
Richard
Patrick | Technical Support Engineer, Senior
Telerik team
commented on 30 Sep 2021, 02:50 PM
Hi Richard,
Thanks for the heads up! I've updated the post above for others looking for assistance.