This is a migrated thread and some comments may be shown as answers.

get_selectedNodes() nodes order

3 Answers 120 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Guillaume Delannoy
Top achievements
Rank 1
Guillaume Delannoy asked on 11 Nov 2013, 02:40 PM
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());
}

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 14 Nov 2013, 11:52 AM
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.
0
Guillaume Delannoy
Top achievements
Rank 1
answered on 15 Nov 2013, 10:12 AM
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.
0
Boyan Dimitrov
Telerik team
answered on 20 Nov 2013, 11:36 AM
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.
Tags
TreeView
Asked by
Guillaume Delannoy
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Guillaume Delannoy
Top achievements
Rank 1
Share this question
or