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

RadTreeView Start partially expanded

1 Answer 54 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
christina noel
Top achievements
Rank 1
christina noel asked on 08 Aug 2011, 11:02 PM
We are trying to construct a File Explorer type of experience for browsing a file structure that is stored in our database. I explored the RadFileExplorer and found that, while it's tree view was good, the file view side would not show a radgrid with customizable/filterable columns without a whole lot of work, so I'm constructing our file explorer by using  a RadTreeView and a RadGrid instead.

Due to the size of the file structure, I decided to use the RadTreeView's LoadOnDemand. I'm currently using ExpandMode=WebService, since I have to go back to the database for the "values" of the nodes and use my business objects to populate the "text" -- but I don't want to have to deal with the overhead of a postback.

I load the root of the file structure during TreeView_Load:
if(!this.IsPostBack)
{
   tvFolders.Nodes.Add(new RadTreeNode("Files", "1"){ExpandMode = TreeNodeExpandMode.WebService});
}

This is working great when I want to start my file explorer in the root node. However, there are cases in my app when I want to start in a subdirectory. (For example: Files/Folder/SubFolder)

I would like to expand the "Files" node (and populate it's children), the "Folder" node (and populate it's children), and select the "SubFolder" node (so that it fires the SelectedIndexChanged event, which populates the RadGrid). I don't know at design time how deep into the tree I'll need to load, but I will know the entire path (both by Text and by Value) by the time I need to populate the tree in OnLoad.

Is this possible with WebService expand? If so, how can I do it? I've tried just setting Node.Expand=true, but that doesn't seem to populate all the children.

--Christina

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 11 Aug 2011, 11:25 AM
Hello Christina,

You will have to manually load the nodes server-side, right to the place where you need to be expanded.

My suggestion is to abstract a method getting a node and returning it's children (connecting to dataSource) and use it in both places - NodeExpand handler and during loading the current path.

Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
TreeView
Asked by
christina noel
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or