Select first tree node

4 posts, 0 answers
  1. Keith Knight
    Keith Knight avatar
    7 posts
    Member since:
    Feb 2010

    Posted 04 Jan 2012 Link to this post

    How do I select the first first node in a kendo treeview?

    Thanks!
  2. Keith Knight
    Keith Knight avatar
    7 posts
    Member since:
    Feb 2010

    Posted 04 Jan 2012 Link to this post

    Here is a possible solution.  Is there a better way?

    selectFirstNode: function (treeId) {
                    var el = $('#' + treeId);
                    var tree = el.data('kendoTreeView');
                    var firstNode = el.find('.k-first');
                    tree.select(firstNode);
                }
  3. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2527 posts

    Posted 04 Jan 2012 Link to this post

    Since the treeview select() method accepts jQuery selectors too, you can shave off some lines:

    selectFirstNode: function(treeId) {
        $("#" + treeId).data("kendoTreeView").select(".k-first");
    }

     

    Regards,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Rafi
    Rafi avatar
    3 posts
    Member since:
    Jan 2012

    Posted 03 Feb 2012 Link to this post

    Hi all,
    To continue this question, I have a 2 level tree and I'm trying to select the first element of the first tree branch.
    I tried the following:

    var first_item = $("#tree_list_id").find(".k-first").find('li').eq(0);
    $("#tree_list_id").data("kendoTreeView").select(first_item);

    Any idea?

    Thanks
    Rafi
Back to Top