OnDemand load nodes with HierarchicalDataSource

14 posts, 1 answers
  1. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 21 Jul 2009 Link to this post

    Hi,

    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...

    Thanks.
  2. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 21 Jul 2009 Link to this post

    I am not sure if you've already checked the documentation, but there is a tutorial on Server-Side Load On Demand here:
    http://www.telerik.com/help/aspnet-ajax/tree_databindingloadondemandserver.html

    There is also a demo of the on-demand load types here:
    http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/loadondemandmodes/defaultcs.aspx

    I'm not sure how this would interact with a Hierarchical DataSource, but hopefully it is helpful.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 21 Jul 2009 Link to this post

    Hi Mr. Plinko,

    It can't work.

    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.

    Thanks.
  5. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 21 Jul 2009 Link to this post

    Sounds like something you should create a support ticket for! If they ultimately can't solve your problem, it might give Telerik some ideas for one of their future releases.
  6. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 21 Jul 2009 Link to this post

    Before creating a support ticket, I am going to wait for the team answer, if I have to open ticket, or if there is an easy workaround.

    Thanks.
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Jul 2009 Link to this post

    Hello Damien,

    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.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 22 Jul 2009 Link to this post

    Hi Albert,

    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.
  9. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Jul 2009 Link to this post

    Hi Damien,

    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:

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

    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.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 22 Jul 2009 Link to this post

    Hi Albert,

    Your idea seems to work well, but I think there may be performance issues :
    • it seams that when loaded the first time, all data is loaded from datasource, but only root nodes are sent to client
    • when expanding a root node, all children are loaded in one time, and sent to client, so ServerSideCallback is not applied. (the effect of the Depth property)
    Is there a way to improve performances by only asking datasource for visible nodes ? This would avoid loading all my 10000 items from database to server memory...
    When I was searching for doc about the "Depth" property, I have found http://www.telerik.com/help/aspnet/treeview/radtreeview-telerik.webcontrols.radtreenodebinding-depth.html, but it seams that in "Remarks" there is an error : RadMenuItemBinding instead of RadTreeNodeBinding (just a too fast copy/past I think).

    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.
  11. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Jul 2009 Link to this post

    Hi Damien,

    Up to your questions:

    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.

    We will fix the documentation problem. Thanks for reporting it.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  12. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 22 Jul 2009 Link to this post

    Hi,

    Is there a way to load only needed nodes (visible nodes) on databinding, avoiding this performance overload ?
    Today, it takes me about 10s to load 10000 items from DbServer to my dev server...

    Do you think it is possible ?

    Thanks.
  13. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Jul 2009 Link to this post

    Hi Damien,

    Unfortunately this is not possible using a hierarchical datasource. You have to use the NodeExpand event , request the required data and populated the child nodes from the returned results.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  14. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 22 Jul 2009 Link to this post

    Hi,

    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.
  15. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Jul 2009 Link to this post

    Hello Damien,

    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.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017