OnDemand load nodes with HierarchicalDataSource

With my problem of CommandButton in node loaded serverside with a callback, I had to code a HierarchicalDataSource.

But the problem is that page load time is very long since the treeview loads all nodes. I have about 10000 nodes, it take 5s to load (localhost) but long long time to execute javascript onload codes. Maybe caused by RadFormDecorator...

Anyway, is there a way to improve RadTreeView working with HierarchicalDataSource to have nodes populated on-demand, with serverside callbacks, and with rendered template controls persistance for event handling ?
It can let users add their own UserControls to a node, thus allowing non-common usages of a treeview...

The sample uses serverside callbacks generated by the treeview, without a declarative datasource (property DataSourceId). All is done in codebehind, by doing yourself database request acording to expanding node.

You could tell me : "you can use your HierarchicalDataSource to achieve this" but it will fall back to the problem I have here.

I think the RadTreeView has to be improved to handle declarative datasource with a "populate on-demand" behavior.
And to handle the problem of programmatically added controls to node, to recreate serverside all expanded nodes to let application handle events correctly.

Atanas Korchev

Currently RadTreeView supports load on demand only bu implementing the NodeExpand event or by using WebService or PageMethods mode.

Also RadTreeView does not automatically recreate after postback any custom controls added in the node's controlls collection. It behaves exactly as the Panel or Placeholder controls - all dynamically added controls must be readded after postback by the developer.

I think that RadTreeView should implement an on-demand loading mode for hierarchical datasource, so it will avoid loading all the items into client : my tree has about 10 000 nodes, it takes about 10min on a good machine under IE8 after first load to have browser not freezing (I think this is due to RadFormDecorator).

Loading on demande using page methods can be used too, but how can I recreate controls tree ? Is there a way to configure treeview to retrigger all "node expand" events, thus allowing to recreate all dynamics controls ? I think it should not be too hard to code.

Thanks.

Answer

Atanas Korchev

Actually there is a way to populate nodes on demand from hierarchical datasource. However you should make sure the ExpandMode property of the parent nodes is not ClientSide (which is the default). Here is an example:

However if you want to use custom controls which fire events you must use ExpandMode="ServerSide". You can wrap the treeview inside RadAjaxPanel to avoid the postback. Custom controls can be instantiated during the NodeCreated event which should fire after postback for all nodes in the treeview.

Is there a way to apply the RadTreeNodeBinding based on data value instead on Depth ? Since the lowest depth of node that can be expanded is not the same, I would like not to set last child nodes expand mode to serversidecallback...

Thanks.

Atanas Korchev

Indeed all nodes are loaded when using databinding. For the time being it is not possible to perform codeless load on demand from hierarchical datasource. Currently the only thing we do is not to render everything as this is the biggest performance hit.

Unfortunately the Depth is the only way to specify a binding. You can however use the NodeDataBound event and set the required node properties based on the underlying data item.

Ok, but if I use the NodeExpand event, the dynamic controls I may add to nodes are created only the first time the node is created... So I fall back to original problem... Maybe you could add a "NodeCreateControls" event in which I can recreate custom controls inside node (from node value) so events that these controls have their viewstate properly restored, and events triggered ?

Thanks.

Atanas Korchev

The NodeCreated event should be the appropriate place do instantiate dynamic controls. Have you tried that? Let me know if you experience any problems with that event. I will try to assemble a sample project.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.