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

Tree inside ComboBox

2 Answers 84 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Karthik Kantharaj
Top achievements
Rank 1
Karthik Kantharaj asked on 26 Apr 2012, 09:40 AM
hi guys

I saw the below link

http://www.telerik.com/community/forums/aspnet/combobox/placing-single-treeview-inside-combobox-dropdown.aspx

and took the code it was in older version and i replaced to newer version and when i run the code
i am getting script error
Code Below:

aspx page
<script type="text/javascript">
        var allowClose = false;
        var comboText = null;
        var comboValue = null;

        function OnClientDropDownClosing(combobox) {
            if (allowClose == true) {
                allowClose = false;

                return true;
            }
            else {
                return false;
            }
        }

        function allowCBClose(allow) {

            allowClose = allow;
        }

        function ProcessClientClick(node) {
            alert(node.Text);
            allowCBClose(true);
        }



        function OnClientItemsRequested(combobox) {
            //var tree = document.getElementById(combobox.Items[0].Attributes.TreeID);
            var treeView = eval(combobox.Items[0].Attributes.TreeID);
            treeView.OnInit();

            //--- Doesn't work--
            //tree.OnInit();

        }
        
</script>
<div onmousedown="allowCBClose(true);">
    <telerik:RadComboBox
        Width="200px"
        DropDownWidth="200px"
        Height="200px"
        ID="ProductOptionComboBox"
        
        Runat="server"
        OnClientDropDownClosing="OnClientDropDownClosing"
        AllowCustomText="true"
        EnableLoadOnDemand="true"
        OnItemsRequested="ItemsRequested"
        OnClientItemsRequested="OnClientItemsRequested"
        >
        <ItemTemplate>
            <div onmouseup="allowCBClose(false);">
                <telerik:RadTreeView
                    ID="ProductOptionTree"
                    runat="server"
                    Height="350"
                    Width="100%"
                    
                    AutoPostBack="false"
                    BeforeClientClick="ProcessClientClick"
                    >
                </telerik:RadTreeView>
            </div>
        </ItemTemplate>
    </telerik:RadComboBox>
    </div>

C# Code
protected void Page_Load(object sender, EventArgs e)
        {

            if (ProductOptionComboBox.Items.Count == 0 )
            {
                Populate();
            }
        }

        private void Populate()
        {
            if (ProductOptionComboBox.Items.Count == 0)
            {
                ProductOptionComboBox.Items.Add(new RadComboBoxItem());
            }

            RadTreeView ProductOptionTree = (RadTreeView)ProductOptionComboBox.Items[0].FindControl("ProductOptionTree");
            ProductOptionTree.Nodes.Clear();

            // communicate the tree's clientside via the attributes collection
            ProductOptionComboBox.Items[0].Attributes["TreeID"] = ProductOptionTree.ClientID;

            RadTreeNode node = new RadTreeNode("ParentNode1");
            node.Nodes.Add(new RadTreeNode("ChildNode1"));
            ProductOptionTree.Nodes.Add(node);

            node = new RadTreeNode("ParentNode2");
            node.Nodes.Add(new RadTreeNode("ChildNode2"));
            ProductOptionTree.Nodes.Add(node);
        }

        protected void ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            Populate();
        }

Attached the Error Image

Karthik.K

2 Answers, 1 is accepted

Sort by
0
Cat Cheshire
Top achievements
Rank 1
answered on 26 Apr 2012, 09:54 AM
Another AJAX control cannot be nested in the combo drop down  if you use  Load on Demand.
http://www.telerik.com/community/forums/aspnet-ajax/combobox/loadondemand-issue.aspx
0
Karthik Kantharaj
Top achievements
Rank 1
answered on 26 Apr 2012, 09:58 AM
Thanks

Is there any option to do

Any Ideas?

Karthik.K
Tags
ComboBox
Asked by
Karthik Kantharaj
Top achievements
Rank 1
Answers by
Cat Cheshire
Top achievements
Rank 1
Karthik Kantharaj
Top achievements
Rank 1
Share this question
or