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

Treeview in combobox with loading child nodes on parent expand

3 Answers 78 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
FlyFish
Top achievements
Rank 1
FlyFish asked on 20 Jan 2012, 11:39 AM
Hi All,
wondering if somebody tried to implement control similar to this one described here: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx
but with child nodes loaded after parent node is expanded (using postback/callback)? Basically it might be useful in case large size of data is present and loading all nodes into treeview is too space/time costly. The control then should make a call to server on each node expand, get child nodes and refresh staying opened all the time. Not sure if this is possible?

3 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 20 Jan 2012, 05:03 PM
Hi Mariusz,

RadTreeView supports the LoadOnDemand feature. It does exactly what you describe. To see the LoadOnDemand feature in action, you can visit the following live demo:
http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/loadondemandmodes/defaultcs.aspx

You can also read how to use LoadOnDemand in the following help article:
http://www.telerik.com/help/aspnet-ajax/treeview-load-on-demand-overview.html 
 
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
FlyFish
Top achievements
Rank 1
answered on 20 Jan 2012, 05:08 PM
Hi Bozhidar,
thank you for your reply. I am aware of this feature of TreeView but the problem is how to use it in example I provided? (combobox + treeview, make combo opened when node expanding and updating)
Regards
0
Bozhidar
Telerik team
answered on 21 Jan 2012, 03:28 PM
Hi Mariusz,

Here's how you can achieve this functionality:

.aspx:
<telerik:RadComboBox ID="RadComboBox1" runat="server">
    <ItemTemplate>
        <div id="div1">
            <telerik:RadTreeView runat="server" ID="RadTreeView1" Height="300">
                <Nodes>
                    <telerik:RadTreeNode Text="Root Node" ExpandMode="ServerSideCallBack" />
                </Nodes>
            </telerik:RadTreeView>
        </div>
    </ItemTemplate>
    <Items>
        <telerik:RadComboBoxItem Text="" />
    </Items>
</telerik:RadComboBox>

.cs
protected void Page_Load(object sender, EventArgs e)
{
    foreach (RadComboBoxItem item in RadComboBox1.Items)
    {
        RadTreeView tree = (RadTreeView)item.FindControl("RadTreeView1");
        tree.NodeExpand += new RadTreeViewEventHandler(tree_NodeExpand);
    }
}
 
void tree_NodeExpand(object sender, RadTreeNodeEventArgs e)
{
    RadTreeNode node = new RadTreeNode("Child Node");
    node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
    e.Node.Nodes.Add(node);
}

 
Kind regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
FlyFish
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
FlyFish
Top achievements
Rank 1
Share this question
or