get_selectedNodes() nodes order

4 posts, 0 answers
  1. Guillaume Delannoy
    Guillaume Delannoy avatar
    2 posts
    Member since:
    Apr 2008

    Posted 11 Nov 2013 Link to this post

    Hi,

    The client side method get_selectedNodes() should return the nodes in order they were selected, this doesnt seems the case anymore...

    Before implementing my own logic I would like to know if this is an issue/bug?

    Thanks

    Here's a snippet : 

    var treeView = $find(RadTreeViewClientId);
     
    var nodes = treeView.get_selectedNodes();
    for (var i = 0; i < nodes.length; i++) {
        console.log("SelectedNode " + i + ": " + nodes[i].get_text());
    }

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 14 Nov 2013 Link to this post

    Hello,

    Thank you for contacting Telerik Support.

    Could you please clarify whether you are facing an issue with our RadTreeView client-side method .get_selectedNodes()? I would like to clarify that I have tested the code snippet and it works as expected. Please note that you have to enable the multi select option for the RadTreeView control by simply setting the property MultipleSelect to true.

    Hope that this will be helpful.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Guillaume Delannoy
    Guillaume Delannoy avatar
    2 posts
    Member since:
    Apr 2008

    Posted 15 Nov 2013 Link to this post

    Hi,

    Yes, I'm having an issue with the RadTreeView client-side method.get_selectedNodes(). 

    When dragging nodes, they are not in the selected order (even before dropping).

    I tried the reproduce the problem with a simple tree and did get the same results (server side this time), should this be the case?

    I followed the example from here : http://www.telerik.com/help/aspnet-ajax/treeview-drag-and-drop-overview.html

    My telerik version is : 2013.3.1015.45

    Thanks.
  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 20 Nov 2013 Link to this post

    Hello,

    I would like to clarify that your observations are correct and the nodes in the RadTreeView client-side method.get_selectedNodes() are not in the same order as they have been selected. When a user selects a new node the collection is sorted so this behavior is expected ( that the selection order is not kept). In order to implement such scenario I would suggest using your own array object to store the selected nodes in order. You can use the RadTreeView client-side event ClientNodeClicked as shown in the code snippet below:
    //JavaScript
    var treeSelectedNodes = new Array();
     
    function clientNodeClicked(sender, args) {
        if (args.get_node().get_selected()) {
            Array.add(treeSelectedNodes, args.get_node());
        }
        else {
           //remove that item since the user unselects the item, so it is not selected anymore
        }
    }

    So in this case instead of using the RadTreeView client-side method .get_selectedNodes() you can use your own Array object and retrieve the selected nodes objects from that array.

    Hope that this will be helpful.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top