destroy

Prepares the widget for safe removal from DOM. Detaches all event handlers and removes jQuery.data attributes to avoid memory leaks. Calls the destroy method of any child Kendo UI widgets.

This method does not remove the widget element from the DOM.

Example - safely removing the TreeList from the DOM

<button id="destroy">Destroy and remove TreeList</button>
<div id="treeList"></div>
<script>
  $("#treeList").kendoTreeList({
    columns: [
      { field: "name" },
      { field: "age" }
    ],
    dataSource: [
      { id: 1, parentId: null, name: "Jane Doe", age: 22, expanded: true },
      { id: 2, parentId: 1, name: "John Doe", age: 24 },
      { id: 3, parentId: 1, name: "Jenny Doe", age: 3 }
    ]
  });
  $("#destroy").click(function(){
    $("#treeList").data("kendoTreeList").destroy(); // destroy the TreeList

    $("#treeList").remove(); // remove all TreeList HTML
  });
</script>
In this article