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

Treeview - Single Expand Path

6 Answers 172 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Aaron Weule
Top achievements
Rank 1
Aaron Weule asked on 09 May 2014, 03:57 PM
Hello,
I'm working with the local data treeview sample.

Is there a way to implement single expand path similar to RadTreeView (http://www.telerik.com/help/aspnet-ajax/treeview-server-single-expand-path.html)? I'd like for only the selected node path to be expanded at any one time. All others paths should be collapsed after node selection

Thanks!

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 13 May 2014, 10:30 AM
Hello,

Here is the code that worked at my side:
<script type="text/javascript">
       function OnClientNodeClicking(sender, args) {
           if (!args.get_node().get_selected() && args.get_node().get_nodes().get_count()>0) {
               args.get_node().expand();
           }
       }
 
       function OnClientKeyPressing(sender, args) {
           setTimeout(function myfunction() {
               if (sender. get_nodes().get_count()>0) {
                   sender.get_selectedNode().expand();
               }
           },50);
       }
 
   </script>
   <telerik:RadTreeView runat="server" ID="RadTreeView1" AccessKey="a" TabIndex="1"
        OnClientKeyPressing="OnClientKeyPressing" OnClientNodeClicking="OnClientNodeClicking" SingleExpandPath="true"  >
       <Nodes>
           <telerik:RadTreeNode Text="node1">
               <Nodes>
                   <telerik:RadTreeNode Text="node11"></telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeNode>
           <telerik:RadTreeNode Text="node2">
                 <Nodes>
                   <telerik:RadTreeNode Text="node21"></telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeNode>
 
           <telerik:RadTreeNode Text="node3">
                 <Nodes>
                   <telerik:RadTreeNode Text="node31"></telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeNode>
       </Nodes>
   </telerik:RadTreeView>

Hope this will be helpful.

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Aaron Weule
Top achievements
Rank 1
answered on 13 May 2014, 04:23 PM
Hello Plamen,
Thanks for the response. However, this solution uses a RadTreeView which already includes a property called SingleExpandPath. I'm looking for a solution for KendoUI Treeview.


Thanks
0
Alex Gyoshev
Telerik team
answered on 14 May 2014, 06:09 AM
Hello Aaron,

The Kendo UI TreeView does not include this functionality out of the box. You can achieve the effect by attaching an expand event handler and calling collapse on nodes that are not in the current path.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Aaron Weule
Top achievements
Rank 1
answered on 14 May 2014, 03:08 PM
I realize Kendo UI TreeView does not include this functionality (hence the reason for this post).

Do you have any examples?
0
Accepted
Alex Gyoshev
Telerik team
answered on 15 May 2014, 07:16 AM
Hello Aaron,

We did not have an example, but here is a Dojo snippet that we made for you.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Aaron Weule
Top achievements
Rank 1
answered on 15 May 2014, 09:24 PM
Excellent - this is exactly what I needed

Thank you for your help
Tags
TreeView
Asked by
Aaron Weule
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Aaron Weule
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or