8 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 30 Nov 2013, 02:57 AM
Hi César
,
The Client side method get_entries() will return all the selected RadDropDownTree Entries Collection. Another methods get_selectedValue() and get_selectedText() will return the value/text of an entry or a collection of entries separated by semicolon. Please have a look into the sample code snippet.
ASPX:
JavaScript:
Hope this will helps you.
Thanks,
Shinu.
The Client side method get_entries() will return all the selected RadDropDownTree Entries Collection. Another methods get_selectedValue() and get_selectedText() will return the value/text of an entry or a collection of entries separated by semicolon. Please have a look into the sample code snippet.
ASPX:
<telerik:RadDropDownTree ID="RadDropDownTree1" runat="server" DataSourceID="SqlDataSource1" DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" CheckBoxes="SingleCheck"></telerik:RadDropDownTree><telerik:RadButton ID="RadButton1" runat="server" Text="GetSelectedNode" AutoPostBack="false" OnClientClicked="OnClientClicked1"></telerik:RadButton>JavaScript:
<script type="text/javascript"> function OnClientClicked1(sender, args) { var tree = $find("<%=RadDropDownTree1.ClientID %>"); //DropDownTree Entries Collection var entries = tree.get_entries(); // get the selected text alert("Selected Text :" + tree.get_selectedText()); }</script>Hope this will helps you.
Thanks,
Shinu.
0
César
Top achievements
Rank 1
answered on 02 Dec 2013, 08:59 AM
Hi,
Thanks for your response, I had already seen those methods but I'm afraid they are not useful for my case.
I am looking to retrieve an specific attribute for the node object (in client side): the level of the selected node.
Which would be the best way to do this?
Thanks
Thanks for your response, I had already seen those methods but I'm afraid they are not useful for my case.
I am looking to retrieve an specific attribute for the node object (in client side): the level of the selected node.
Which would be the best way to do this?
Thanks
0
Shinu
Top achievements
Rank 2
answered on 02 Dec 2013, 09:38 AM
Hi
César,
Please have a look into the following code snippet to get the level of the selected node of RadDropDownTree.
JavaScript:
Thanks,
Shinu.
Please have a look into the following code snippet to get the level of the selected node of RadDropDownTree.
JavaScript:
<script type="text/javascript"> function OnClientClicked1(sender, args) { var tree = $find("<%=RadDropDownTree1.ClientID %>"); alert("Level :" + tree.get_embeddedTree().get_selectedNode().get_index()); }</script>Thanks,
Shinu.
0
César
Top achievements
Rank 1
answered on 02 Dec 2013, 11:58 AM
Hi,
Thanks for your response. Your example works. I also found that you can retrieve the selected node from the "eventArgs" object in the OnClientEntryAdded event:
OnClientEntryAdded="onEntryAdded"
The point now is that "get_index()" does not retrieve the level (sorry for mixing two topics here):
ElementA (Level 0) (Index 0)
SubElement (Level 1) (Index 0)
ElementB (Level 0) (Index 1)
SubElementB (Level 1) (Index 1)
SubElementFromSubElementB (Level 1) (Index 1)
Do I need to write a function that iterates the parent nodes to get the Level?
Regards
Thanks for your response. Your example works. I also found that you can retrieve the selected node from the "eventArgs" object in the OnClientEntryAdded event:
OnClientEntryAdded="onEntryAdded"
function onEntryAdded(sender, eventArgs) { var selectedNode = eventArgs.get_entry(); }
The point now is that "get_index()" does not retrieve the level (sorry for mixing two topics here):
ElementA (Level 0) (Index 0)
SubElement (Level 1) (Index 0)
ElementB (Level 0) (Index 1)
SubElementB (Level 1) (Index 1)
SubElementFromSubElementB (Level 1) (Index 1)
Do I need to write a function that iterates the parent nodes to get the Level?
Regards
0
Accepted
Hello,
An easy and convenient way of getting the selected node level in the OnClientEntryAdded would be:
//markup code
//JavaScript
Regards,
Boyan Dimitrov
Telerik
An easy and convenient way of getting the selected node level in the OnClientEntryAdded would be:
//markup code
<telerik:RadDropDownTree ID="RadDropDownTree1" runat="server" DefaultMessage="Select location" Skin="Default" OnClientEntryAdded="onEntryAdded" EnableFiltering="true" FilterSettings-Highlight="Matches"></telerik:RadDropDownTree>function onEntryAdded(sender, eventArgs) { //finds the text value of the entry var entryText = eventArgs.get_entry().get_text(); //gets the embedded tree object var embeddedTree = sender.get_embeddedTree(); //find the node object based on the entry text ( it is actually the node's text) var entyNode = embeddedTree.findNodeByText(entryText); //gets the node level alert(entyNode.get_level());}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
César
Top achievements
Rank 1
answered on 05 Dec 2013, 11:44 AM
Thanks.
This answer covers all the topic.
Regards
This answer covers all the topic.
Regards
0
Prahlad
Top achievements
Rank 1
answered on 27 Mar 2015, 10:47 AM
hii
can any one tell me how to expend the node if i select the child node then only that root node will be expend instead of other nodes.
can any one tell me how to expend the node if i select the child node then only that root node will be expend instead of other nodes.
0
Hello,
To achieve that you can access the RadTreeView embedded in the RadDropDownTree and add the following OnClientNodeExpanding event handler:
And then
Regards,
Ivan Danchev
Telerik
To achieve that you can access the RadTreeView embedded in the RadDropDownTree and add the following OnClientNodeExpanding event handler:
protected void Page_Load(object sender, EventArgs e){ RadTreeView tree = RadDropDownTree1.EmbeddedTree; tree.OnClientNodeExpanding = "OnClientNodeExpanding"; tree.NodeClick += tree_NodeClick;}function OnClientNodeExpanding(sender, args) { var node = args.get_node(); var tree = node.get_treeView(); var nodes = tree.get_allNodes(); for (var i = 0; i < nodes.length; i++) { if (nodes[i].get_nodes() != null) { nodes[i].collapse(); } }}And then
Regards,
Ivan Danchev
Telerik
See What's Next in App Development. Register for TelerikNEXT.
