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

Expand only one Node

2 Answers 156 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nirmal
Top achievements
Rank 1
Nirmal asked on 30 Jul 2009, 10:41 AM
Hi,
  I have a treeview that cause automatically expand   the parent nodes when you click it on the Client in order to see their childs.
I would like to expand only one parent node at a time.If i expand another one the previous node should automatically collapsed?
How can I?

Nirmal

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2009, 10:04 AM
Hi Nirmal,

Set the SingleExpandPath="True" in order to collapse all nodes automatically that are not on the path of the currently expanded Node.

<telerik:RadTreeView ID="RadTreeView1" runat="server" SingleExpandPath="True">
</telerik:RadTreeNode>

-Shinu.
0
Srujana
Top achievements
Rank 1
answered on 26 Sep 2011, 03:45 PM
Hi Shinu..

This seems to be a cool feature and working great, but when I try to reopen the collapsed node and expand the child nodes of it, it is taking more time to expand(compared to what it takes when the node is not collapsed by this feature), any ideas on why it would take longer if the node is collased and re-expanded. My treeviee has 4 levels, all are loaded on demand using serversidecallback. here is my serverside code to populate nodes on demand.

private static void PopulateNodeOnDemand(RadTreeNodeEventArgs e, string level, TreeNodeExpandMode expandMode)
      {
          int parentID = Convert.ToInt32(e.Node.Value);
          IEnumerable<TreeNodeData> results = null;
          if (level == "1")
          {
              results = TD.Get.TreeView.Units.BySite(parentID);
          }
          else if (level == "2")
          {
              results = TD.Get.TreeView.Routes.ByUnit(parentID);
          }
          else if (level == "3")
          {
              results =TD.Get.TreeView.Stops.ByRoute(parentID);
          }
          else if (level == "4")
          {
              results =TD.Get.TreeView.Tasks.ByStop(parentID, Convert.ToInt32(e.Node.ParentNode.Value));
          }
          if (results != null && results.Count() > 0)
          {
              results = results.OrderBy(a => a.NodeTitle);
              foreach (TreeNodeData item in results)
              {
                  RadTreeNode node = new RadTreeNode();
                  node.Text = item.NodeTitle;
                  node.Value = item.NodeId.ToString();
                  node.ImageUrl = ImageUrl;
                    if (Convert.ToInt32(item.ChildrenCount) > 0)
                  {
                      node.ExpandMode = expandMode;
                  }
                  e.Node.Nodes.Add(node);
              }
          }
          e.Node.Expanded = true;
           
      }

Please let me know if you see any issues with the code.

Thanks,
Srujana.
Tags
TreeView
Asked by
Nirmal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Srujana
Top achievements
Rank 1
Share this question
or