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

TreeView expandTo not working

1 Answer 436 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Hwigyeom
Top achievements
Rank 1
Hwigyeom asked on 26 Dec 2017, 06:44 AM
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>
 
 
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>
<body>
   
<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
  loadOnDemand: false,
  dataSource: [
    { text: "foo", items: [
      { text: "bar", items: [
        { text: "baz" }
      ] }
    ] },
    { text: "one", items: [
      { text: "two", items: [
        { text: "three" }
      ] }
    ] }
  ]
});
 
var treeview = $("#treeview").data("kendoTreeView");
 
var baz = treeview.dataItem(treeview.findByText("baz"));
console.log('baz', baz);
treeview.expandTo(baz);
 
 
// expand all nodes up to "three"
var three = treeview.dataItem(treeview.findByText("three"));
console.log('three', three);
treeview.expandTo(three);
 
</script>
</body>
</html>

When the id field is removed from the snippet, 'three' item in the expandTo call is not expanded.

I remember that the above code worked fine in the 2015.1.422 version.

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 26 Dec 2017, 07:45 AM
Hi,

In such scenarios we recommend having IDs that will make difference in the nodes and assure correct behavior as for example it is done in our documentation here.

Regards,
Plamen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TreeView
Asked by
Hwigyeom
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or