Expand and Select Node with ID in TreeView

2 posts, 1 answers
  1. Answer
    Dietmar avatar
    10 posts
    Member since:
    May 2012

    Posted 12 Jul 2013 Link to this post


    I'm almost done with the code from the subject. The tree expands already to the given ID, but unfortunately it does not select the node given by ID

    Edit: Just to clarify, because I read a few threads regarding this issue - I don't get any error messages nor do I get 'undefined' for any variables. The node just doesn't get selected.

    function expandAndSelectNode(id, treeViewName) {
        // get the Kendo TreeView widget by it's ID given by treeviewName
        var treeView = $(treeViewName).data('kendoTreeView');
        // find node with data-id = id
        var item = $(treeViewName).find("li[data-id='" + id + "']").find(".k-in");
        // expand all parent nodes
                    function (index, element) {
        // get DataSourceItem by given id
        var nodeDataItem = treeView.dataSource.get(id);
        //get node within treeview widget by uid
        var node = treeView.findByUid(nodeDataItem.uid);


    I also tried $(treeView).select(item), since it should already point to the <span> item I want to select anyway. This didn't work.
    Then I tried tried $(treeView).select(item.closest('.k-item')), since it points to the parent <li> element, but this didn't work either.
     The uncommented line (treeView.select(".k-item:last")) was just for testing and works.

    I'm a little bit stuck and glad about any hints.

  2. Daniel
    Daniel avatar
    2110 posts

    Posted 16 Jul 2013 Link to this post


    The treeview object should not be wrapped in order to use the treeview methods and not the jQuery methods e.g.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top