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

Dynamic ComboBox with Treeview

6 Answers 137 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 20 May 2008, 06:57 PM
I need to build a RadComboBox containing a RadTreeView dynamically in the codebehind with nothing more than a placeholder on the aspx page. I am easily able to do one or the other, but combining the two seems to be a bit trickier. Has anyone attempted this before? Any examples if it can be done would be greatly appreciated.

Thanks!

Paul

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 22 May 2008, 10:22 AM
Hi Paul,

Check out the demo link given below.
TreeView in ComboBox

Shinu.
0
Paul
Top achievements
Rank 1
answered on 22 May 2008, 12:55 PM
Hi Shinu,

Thanks for the reply. I've seen that example and unfortunately that's not what I need. I need to build the ComboBox/TreeView entirely in the codebehind, not in the aspx page as the sample you sent shows.

Or if not possible, a way to add a treeview  to a combobox dynamically would work as well (all the clientside javacript needed on the aspx page doesn't need to be added dynamically)

Thanks,

Paul
0
Veselin Vasilev
Telerik team
answered on 23 May 2008, 01:08 PM
Hi Paul,

Have you checked the article about adding templates at runtime? You can find it here:
http://www.telerik.com/help/aspnet-ajax/combo_templatesaddingtemplates.html
Scroll down to find how to add templates at runtime.

Let me know if you have additional questions.

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
MrHoso
Top achievements
Rank 1
answered on 23 May 2008, 01:27 PM
Hi Paul,

If you want to add RadTreeView, firstly you must define a class that implements the ITemplate interface
    Public Class RadComboboxTreeView  
        Implements System.Web.UI.ITemplate  
        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn  
            Dim rTree As Telerik.Web.UI.RadTreeView = New Telerik.Web.UI.RadTreeView  
            rTree.CheckBoxes = True 
            Dim pNode As Telerik.Web.UI.RadTreeNode = New Telerik.Web.UI.RadTreeNode("Item")  
            pNode.Expanded = True 
            For i As Integer = 1 To 6  
                pNode.Nodes.Add(New Telerik.Web.UI.RadTreeNode("Item " & i, i))  
            Next  
            rTree.Nodes.Add(pNode)  
            container.Controls.Add(rTree)  
        End Sub  
    End Class 

and then you can add treeview to combobox like that

Dim ddl As Telerik.Web.UI.RadComboBox = New Telerik.Web.UI.RadComboBox  
ddl.ID = "ddl" 
ddl.ItemTemplate = New PI.RadComboboxTreeView(repObj, PI.Utility.AppSkin, ID)  
ddl.Items.Add(New Telerik.Web.UI.RadComboBoxItem())  
Page.Form.Controls.Add(ddl) 

I hope it can help you,

Regards

Ahmet HOSO
0
JARROD R
Top achievements
Rank 1
answered on 29 May 2008, 01:04 AM
Is there anyway to do this with a treeview that will Load on Demand?

Our application has a page that could have 3 of these treeview/comboBox controls, but there is the possibility that the treeviews could have a lot of nodes.  There would be too much information to be loaded at one time. 

I tried to to create a load on demand, but the combobox closes every time the server is called.  Any suggestions?

Thanks
0
Veselin Vasilev
Telerik team
answered on 29 May 2008, 08:37 AM
Hi JARROD RUEZ,

You can check this code library: Load on demand TreeView in Combobox

I hope this helps.

Greetings,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Veselin Vasilev
Telerik team
MrHoso
Top achievements
Rank 1
JARROD R
Top achievements
Rank 1
Share this question
or