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

Treeview with an IHierarchicalDataSource

4 Answers 204 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Hans asked on 24 Nov 2008, 11:53 PM
Hello

I've been playing around with the RadTreeView control to bind it to custom business objects using a custom implemented IHierarchicalDataSource. I have found a sample data source control in the Telerik forums that shows the directory/file structure of the website (forum article: http://www.telerik.com/community/forums/aspnet/treeview/treeview-binding-to-business-object.aspx#274329; sample code: http://msdn.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx).


The issue I'm having is to implement a true 'load on demand' with the RadTreeView. If I use the sample code for the HierarchicalDataSource provided by Microsoft using the standard ASP.NET Treeview control, the 'load on demand' occurs appropriate: only when child nodes are required from a client-expand, the child-nodes are actually loaded on the server (you can check this by e.g. setting a break-point in the 'Select' method of the 'FileSystemDataSourceView'.

The code I'm using for this:

 

<demo:FileSystemDataSource ID="FileSystemDataSource1" runat="server"></demo:FileSystemDataSource>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="FileSystemDataSource1" ExpandDepth="0"></asp:TreeView>
Please note that the ExpandDepth must be set to '0' and not 'FullyExpand': I only want to load the nodes that the user requests, because in my case there can be hundreds, even thousands of nodes.


Now, when I change the ASP.NET Treeview into a RadTreeView, all childs are loaded with all children (so, recursive which returns the full hierarchical structure) on the first hit to the page (as if a FullyExpand is required). You can check this by setting a break-point in the GetChildren method of the 'FileSystemHierarchyData'. 

The code used for this approach:

 

<demo:FileSystemDataSource ID="FileSystemDataSource1" runat="server"></demo:FileSystemDataSource
<telerik:RadTreeView ID="RadTreeView1" Runat="server" DataSourceID="FileSystemDataSource1"></telerik:RadTreeView>

 



Using a structure as shown below is a real performance killer, which isn't the case when using the standard ASP.NET Treeview control:
Top_1
    Level 1_1
        Level 1_1_1
        Level 1_1_2
        ...
        Level 1_1_50
    Level 1_2
        Level 1_2_1
        Level 1_2_2
        ...
        Level 1_2_50
    ...
    Level 1_50
        Level 1_50_1
        Level 1_50_2
        ...
        Level 1_50_50
Top_2
    Level 2_1
    ....
        Level 2_50_50


I've tried to change the properties of the RadTreeView to modify this behavior, but with no success.
Am I missing something here? Any suggestions?

As a side-question: can the RadTreeView handle in a proper manner lets say a thousand child nodes for one given parent?

Thanks
Hans

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 Nov 2008, 10:28 AM
Hi Hans,

RadTreeView does not support this feature at the time being - when binding to hierarchical datasource all nodes are populated instantly. If you need load on demand you should subscribe to the NodeExpand event as demonstrated in this online example.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hans
Top achievements
Rank 1
answered on 25 Nov 2008, 01:48 PM

Albert,

Thanks for the quick reply, it is highly appreciated!

Just to make sure: are there other solutions to get this ‘true’ load-on-demand beside connecting to the NodeExpand method?

Kind regards,
Hans  

0
Accepted
Atanas Korchev
Telerik team
answered on 25 Nov 2008, 02:17 PM
Hello Hans,

RadTreeView supports load on demand via setting the ExpandMode property of the node. Then you need to either use web service load on demand or subscribe to the NodeExpand event.

The closest thing we have right now is using a binding so the nodes are rendered on demand on expanding. The databinding will be still complete though - only nodes which are expanded will be rendered. Here is an example with the XmlDataSource:

    <telerik:RadTreeView runat="Server" ID="RadTreeView1" CheckBoxes="True" CheckChildNodes="True" DataSourceID="XmlDataSource1" DataTextField="Text">
        <DataBindings>
            <telerik:RadTreeNodeBinding ExpandMode="ServerSideCallBack" Depth="0" />
        </DataBindings>
    </telerik:RadTreeView>
       
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="/Nodes/Node">
            <Data>
                <Nodes>
                    <Node Text="Root">
                        <Node Text="Child"></Node>
                    </Node>
                </Nodes>
            </Data>
        </asp:XmlDataSource>

I hope this helps,
Atanas Korchev,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hans
Top achievements
Rank 1
answered on 26 Nov 2008, 09:15 AM
Hi Albert,

Again, thanks for the reply.

The web service approach is definitly the one I need and, with only a littble more work,  solves the issue.

Thanks for the pointing me to the solution
Hans
Tags
TreeView
Asked by
Hans
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Hans
Top achievements
Rank 1
Share this question
or