Version

Load-on-demand

WebDataTree™ supports load-on-demand functionality. When load-on-demand is enabled you can avoid any excessive initial processing of the page.

Using Load-on-demand in WebDataTree.

WebDataTree™ handles very large amounts of data without incurring any loss in performance with its load-on-demand feature enabled. You can decide on how many nodes to initially load by setting the WebDataTree control’s InitialDataBindDepth property. By default, the InitialDataBindDepth property is set to -1, which means all the nodes are initially loaded. The value that you specify for the InitialDataBindDepth property represents the index of the last level that is to be initially loaded. For example, if you set this property to a value of 1, then level 0 (the first level of nodes) and level 1 (the second level of nodes) will be loaded upon the initial page rendering. Subsequent levels with an index of 2, 3 and so forth will be loaded on demand.

If you want to learn how to use load-on-demand in WebDataTree, follow this steps.

  1. From the Visual Studio™ Toolbox, drag and drop a ScriptManager component, a WebDataTree control and a WebHierarchicalDataSource control.

  2. Bind the WebDataTree to WebHierarchicalDataSource as shown in the Binding WebDataTree to WebHierarchicalDataSource topic.

  3. Set the InitialDataBindDepth and DataLoadingMessage properties as shown in the following code :

In Visual Basic:

        WebDataTree1.InitialDataBindDepth = 0
        WebDataTree1.DataLoadingMessage = "Loading...Please wait!"

In C#:

        WebDataTree1.InitialDataBindDepth = 0;
        WebDataTree1.DataLoadingMessage = "Loading...Please wait!";

In the above code, setting the InitialDataBind property to 0 allows only the first level of nodes to be bound to the tree. The remaining nodes will be bound on demand.

  1. Save and run your application. You will observe that when you expand the nodes, the data loading message “Loading…Please wait!” will appear first and then the corresponding child nodes are loaded.

Using data loading template in WebDataTree.

When using the load-on-demand feature, WebDataTree allows you to show a customized loading message by setting the DataLoadingMessage property. However you can also apply a data loading template to the loading message using the WebDataTree control’s DataLoadingTemplate property. DataLoadingTemplateContainer is the container control for the WebDataTree control’s data loading template. If you want to set and use template for WebDataTree loading message, follow the next steps.

  1. From the Visual Studio™ Toolbox, drag and drop a ScriptManager component and a WebDataTree control onto the form.

  2. In the source code, include the following code between the WebDataTree tags to show the loading message using the DataLoadingTemplate tags.

In HTML :

<DataLoadingTemplate>
                <div id="loadTemplate" style="background-color : Aqua">
                    <span id="actualMsg">Loading, please wait…</span>
                </div>
</DataLoadingTemplate>
  1. Save and run your application. When you expand the nodes for the first time, you will observe that the data loading template is applied to the loading message.