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

TreeView inside ComboBox

2 Answers 123 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Oscar
Top achievements
Rank 1
Oscar asked on 14 May 2012, 05:31 PM

I fill a treeView with Type object (MyCollection : List<MyType>, IHierarchicalEnumerable)
and work perfect but now I need set the datasource of a treeView inside a combox:

<telerik:RadComboBox ID="RadComboBox1" runat="server">
<ItemTemplate>
<telerik:RadTreeView ID="RadTreeView2" runat="server" >
</telerik:RadTreeView>
</ItemTemplate>
</telerik:RadComboBox>

 

How I do that?

I been try this:
var tree = new RadTreeView {DataSource = _categoryCollection};
            tree.DataBind();
            RadComboBox1.Controls.Add(tree);
            RadComboBox1.DataBind();

The treview fill ok , But combobox does not show anything. 

I need some like this

http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx

 

 

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 15 May 2012, 01:18 PM
Hello Oscar,

You markup should look like so:

<telerik:RadComboBox ID="RadComboBox1" runat="server">
    <ItemTemplate>
        <telerik:RadTreeView ID="RadTreeView2" runat="server" >
        </telerik:RadTreeView>
    </ItemTemplate>
    <Items>
        <telerik:RadComboBoxItem Text="" />
    </Items>
</telerik:RadComboBox>

You'll notice that there is an empy RadComboBoxItem, which is used to load the RadTreeView.

When populating the RadTreeView, you need to access it like so:

var treeView = (RadTreeView)RadComboBox1.Items[0].FindControl("RadTreeView2");
// add code to populate treeview

I hope that helps.
0
Oscar
Top achievements
Rank 1
answered on 15 May 2012, 11:19 PM

 

now work fine. Thank you  Kevin
Tags
ComboBox
Asked by
Oscar
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Oscar
Top achievements
Rank 1
Share this question
or