TreeView expandTo not working

2 posts, 0 answers
  1. Hwigyeom
    Hwigyeom avatar
    1 posts
    Member since:
    May 2014

    Posted 26 Dec 2017 Link to this post

    <!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.

  2. Plamen
    Admin
    Plamen avatar
    2824 posts

    Posted 26 Dec 2017 Link to this post

    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.
Back to Top