Select last item inside node

2 posts, 0 answers
  1. Tayger
    Tayger avatar
    117 posts
    Member since:
    Jan 2015

    Posted 29 Jun Link to this post

    Hello there

    I'm wondering if it is possible to select the last item inside a node. Example:

    A +             (main node)
       A1 +        (child node of A)
       A2 +        (child node of A)
    B +             (main node)

    The plus sign (icon) behind each item is kinda an add item functionality inside that node. F.e. if I click on the + behind the A it would create a child item inside its node, in this case A3 + :

    A +            (clicked on the +)
       A1 +
       A2 +
       A3 +      (new item created)
    B +

    That works fine. What I want now after creating a newitem that way is to SELECT (jump) the newly created item:

    A +
       A1 +
       A2 +
       A3 +    (item is selected)
    B +

    I'm aware of this: treeview.select(".k-item:last");

    In my case it would jump to B + (always to the end of the very last item. Can I somehow (easily) restrict the "last" so it would jump to the last element inside the node I have added a new item?

    Regards

  2. Tayger
    Tayger avatar
    117 posts
    Member since:
    Jan 2015

    Posted 30 Jun in reply to Tayger Link to this post

    Found a solution, no answer required (except there is a way easier one ;) ):

    // Get the selected item in which the new item will be created
    var dialogTree = $("#dialogtreediv").data("kendoTreeView");
    var selectItem = dialogTree.select();
    var dialogItem = dialogTree.dataItem(selectItem);
     
    // Find the UID of the new item inside the selected node
    var newItemUid = $("li[data-uid='"+dialogItem.uid+"'] ul > li:last").attr('data-uid');
    // Select the newly item
    dialogTree.select(dialogTree.findByUid(newItemUid));

     

Back to Top