Dev
Dev

Reputation: 1020

Not able to populate Kendo Tree View properly based on combo box selection in Kendo UI

I want to populate the Kendo treeview with different values based on a Kendo combo box selection, I created a jsfiddle to illustrate my problem.

http://jsfiddle.net/KendoDev/Z4rwQ/3/

In this example, When Combo box value is ClassA, then If I select any node then selected node details are displayed in the message box properly, when I select ClassB then TreeView is not populated at all, to achieve this I need to empty the DOM before re populating treeview.

 `$( "#treeview" ).empty();` . 

If I do this, then when changing the combo box selection, tree view is re populated properly.

But If I select any nodes for ClassB selection then treeview is becoming in operable, Even if I go back to ClassA selection, that option is also not working, any help on what is going wrong here?

Upvotes: 0

Views: 240

Answers (1)

Mark
Mark

Reputation: 108537

You can not just empty the widgets parent div and recreate the widget. You first have to destroy it.

var tV = $("#treeview").data("kendoTreeView");
if (tV){
    tV.destroy();
}
$( "#treeview" ).empty();

Updated fiddle.

Upvotes: 1

Related Questions