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

(Dropdown Treeview) the text of the drop down is blank the first time selecting the node

16 Answers 341 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Apr 2008, 12:17 AM

I am seeing an issue with having a Drop Down Tree View and having the drop down text area set at run time, the issue is when I select a tree view node the first time, the drop down text area becomes blank. But selecting a second node and then after, the drop down text area shows the selected node.

The interesting part is the first select I am able to get the node’s data that was selected, which I use with “comboBox.set_text(node.get_text());” to set the drop down text area. Although the comboBox object shows that its text was set, the page still shows the drop down text area as blank.  

I tried multiple approaches to try to solve this but each one ending  up in the same result.

If I do not set the drop down text at run time, then the issue of selecting a node the first time goes away. I need to have the drop down text set at run time.

I implemented the Drop Down Tree View control into two user controls; one control to handle the Drop Down and the other to handle the Tree View.  I have included the code, the .ascx, .cs and .js info of the controls with some explanation of each

Drop Down  .ascx Page

Simple enough just the drop down that has the tree view user control embedded and the OnClientNodeClicked is handled by the javascript.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucOrgTreeViewDropDown.ascx.cs" Inherits="WebControls_ucOrgTreeViewDropDown" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<%@ Register src="../WebControls/ucOrgTreeView.ascx" tagname="ucOrgTreeView" tagprefix="uc1" %> 
 
<telerik:RadComboBox  
    ID="OrgComboBox"   
    runat="server"   
    Height="140px"   
    Width="215px" 
    ShowToggleImage="True"   
    Skin="MyApp"   
    EnableEmbeddedSkins="false" 
    style="vertical-align:middle;" 
    > 
    <ItemTemplate> 
        <div id="div1" onclick="MyApp.Controls.ucOrgTreeViewDropDown.StopPropagation">  
            <uc1:ucOrgTreeView ID="OrgTreeView" runat="server" OnClientNodeClicked="MyApp.Controls.ucOrgTreeViewDropDown.HandleNodeClicked"/>  
        </div> 
    </ItemTemplate> 
    <Items> 
        <telerik:RadComboBoxItem Text="" /> 
    </Items> 
</telerik:RadComboBox> 
 

Drop Down .cs  File

The Drop Down properties is setup to be a pass through to the Tree View control. OnPreRender method sets up what javascript file will be used. And the OnLoad method will set the Drop Down text area to the selected Node Text on load of the dropdown control by doing the following:

WebControls_ucOrgTreeView
orgtree = (WebControls_ucOrgTreeView)item.FindControl("OrgTreeView");

OrgComboBox.Text = orgtree.SelectedOrgName;

, which works great, the text of the selected node shows up just fine on load. However I wonder if I need to do something else here to force the node to be selected, which I attempted to do with:

int treeviewNodeIndex = orgtree.GetIndexFromOrgID(orgtree.SelectedOrgID);

orgtree.SelectNode = treeviewNodeIndex; 

But this did not help.

using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Configuration;  
using System.Data;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
using Telerik.Web.UI;  
 
public partial class WebControls_ucOrgTreeViewDropDown : System.Web.UI.UserControl  
{  
    // Properties  
    public int SelectedOrgID  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return Convert.ToInt32(tree_view.SelectedOrgID);  
        }  
        set 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            tree_view.SelectedOrgID = value;  
        }  
    }  
 
    public int FirstOrgID  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return tree_view.FirstOrgID;  
        }  
    }  
 
    public string SelectedOrgName  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return tree_view.SelectedOrgName;  
        }  
    }  
 
    public bool UseAllOrg  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return tree_view.UseAllOrg;   
        }  
        set 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            tree_view.UseAllOrg = value;   
        }  
    }  
 
    public bool Enabled  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return tree_view.Enabled;   
        }  
        set 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            tree_view.Enabled = value;  
        }  
    }  
 
    public int RootOrgID  
    {  
        get 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            return tree_view.RootOrgID;  
        }  
        set 
        {  
            WebControls_ucOrgTreeView tree_view = (WebControls_ucOrgTreeView)(OrgComboBox.Items[0].FindControl("OrgTreeView"));  
            tree_view.RootOrgID = value;  
        }  
    }  
 
    // Methods  
    protected override void OnPreRender(EventArgs e)  
    {  
        base.OnPreRender(e);  
        ScriptManager.RegisterClientScriptInclude(thisthis.GetType(), "MyApp.Controls.ucOrgTreeViewDropDown", ResolveClientUrl("~/js/script_handler.ashx?s=~/js/Controls/ucOrgTreeViewDropDown.js"));  
    }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!IsPostBack)  
        {  
            string assign_OrgComboBox_ID = string.Format("var {0} = new MyApp.Controls.ucOrgTreeViewDropDown('{1}', '{2}');\n", ID, OrgComboBox.ClientID, OrgComboBox.Items[0].FindControl("OrgTreeView").FindControl("RadTreeView1").ClientID);  
            ScriptManager.RegisterStartupScript(thisthis.GetType(), string.Format("assign_{0}", ID), assign_OrgComboBox_ID, true);  
      
            foreach (RadComboBoxItem item in OrgComboBox.Items)  
            {  
                RadTreeView tree_view = (RadTreeView)(item.FindControl("OrgTreeView").FindControl("RadTreeView1"));  
                tree_view.Attributes.Add("ParentComboBoxID", OrgComboBox.ClientID);  
                  
                WebControls_ucOrgTreeView orgtree = (WebControls_ucOrgTreeView)item.FindControl("OrgTreeView");  
                OrgComboBox.Text = orgtree.SelectedOrgName;  
                int treeviewNodeIndex = orgtree.GetIndexFromOrgID(orgtree.SelectedOrgID);  
                orgtree.SelectNode = treeviewNodeIndex;               
            }  
        }  
    }  
 
}  
 

Tree View .ascx file

Simple enough just the RadTreeView

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucOrgTreeView.ascx.cs" Inherits="WebControls_ucOrgTreeView" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
 
<telerik:RadTreeView   
    runat="server"   
    ID="RadTreeView1"   
    Skin="MyApp"   
    EnableEmbeddedSkins="false">    
</telerik:RadTreeView> 
 

Tree View .cs file

Some of this code is specific to my application, especially when it comes to getting the org info. On my box the treeview is created just fine and so I suspect the way that it is created is not the issue. ,

However the code does show some of the properties that are used in javascript. The property of SelectedOrgID will return the ID of the row that was selected. The UseAll, just creates a new node with the Text value of “All” and an ID of 0, etc.

using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Configuration;  
using System.Data;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
using Telerik.Web.UI;  
using Medicity.MyApp.BusinessLogic;  
using Medicity.MyApp.CommonObjects;  
using Medicity.MyApp.TestScripts;  
 
public partial class WebControls_ucOrgTreeView : System.Web.UI.UserControl  
{  
    private Medicity.MyApp.BusinessLogic.BusinessLogic bl = new BusinessLogic();  
    private SessionManager sm = new SessionManager();  
    private bool _UseAllOrg = false;  
    private bool _Enabled = true;  
    private int _RootOrgID = -1;  
    private int _SelectedOrgID;  
    private RadTreeNode _SelectedNode = new RadTreeNode();
    
    #region Properties  
    public int SelectedOrgID  
    {  
        get 
        {  
            if (RadTreeView1.SelectedNode != null)  
                return Convert.ToInt32(RadTreeView1.SelectedNode.Value);  
            return -1;  
        }  
        set 
        {  
            _SelectedOrgID = value;  
            ApplyTelerikOrgTreeViewProperties();  
        }  
    }  
 
    public int SelectNode  
    {  
        set   
        {   
            int index = value;  
            RadTreeView1.Nodes[index].Selected = true;  
        }  
    }  
 
    public RadTreeNode SelectedNode  
    {  
        get 
        {  
            return RadTreeView1.SelectedNode;  
        }  
    }  
 
    public int FirstOrgID  
    {  
        get   
        {   
            return Convert.ToInt32(RadTreeView1.Nodes[0].Value);  
        }  
    }  
 
    public string SelectedOrgName  
    {  
        get 
        {  
            if (RadTreeView1.SelectedNode != null)  
                return RadTreeView1.SelectedNode.Text;  
            return string.Empty;  
        }  
    }  
 
    public string OnClientNodeClicked  
    {  
        set 
        {  
            RadTreeView1.OnClientNodeClicked = value;  
        }  
    }  
 
    public bool UseAllOrg  
    {  
        get 
        {  
            return _UseAllOrg;  
        }  
        set 
        {  
            _UseAllOrg = value;  
            ApplyTelerikOrgTreeViewProperties();  
        }  
    }  
 
    public bool Enabled  
    {  
        get 
        {  
            return _Enabled;  
        }  
        set 
        {  
            _Enabled = value;  
            ApplyTelerikOrgTreeViewProperties();  
        }  
    }  
 
    public int RootOrgID  
    {  
        get 
        {  
            return _RootOrgID;  
        }  
        set 
        {  
            _RootOrgID = value;  
            ApplyTelerikOrgTreeViewProperties();  
        }  
    }
    #endregion  
 
    /// <summary>  
    /// The Tree View will be populated with all Orgs of the BOrg before the Properties are applied  
    /// </summary>  
    /// <param name="sender"></param>  
    /// <param name="e"></param>  
    protected void Page_Init(object sender, EventArgs e)  
    {  
        PopulatedAllOrgsIntoTreeView();   
    }  
 
    private void PopulatedAllOrgsIntoTreeView()  
    {  
        List<Org> orgs = new List<Org>();  
        orgs = bl.GetBorgOrgs(sm.UserData.Org.BorgID);  
        orgs = bl.GenerateOrgHierarchies(orgs, false);  
        RadTree_GenerateOrgHierarchies(orgs, false);      
    }  
 
    /// <summary>  
    /// Apply the Properties  
    /// </summary>  
    /// <param name="treeNodeCollection"></param>  
    private void ApplyTelerikOrgTreeViewProperties()  
    {  
        //Reduce the tree list to what is viewable  
        if (_RootOrgID > -1)   
        {  
            List<Org> orgs = new List<Org>();  
            orgs = GenerateOrgHierarchies(); //FOR TESTING ONLY DO NOT ERASE  
            if (_RootOrgID != 0)  
            {  
                //Put code in here to reduce the number of orgs the user is able to view  
            }  
            if (orgs.Count > 0)  
            {   
                RadTree_GenerateOrgHierarchies(orgs, true); //This sets up the TreeView with Org data  
            }  
            else 
            {  
                throw new ApplicationException("What The");  
            }  
        }  
 
        //Create the tree list if the list is empty  
        if (RadTreeView1.Nodes.Count == 0)  
            PopulatedAllOrgsIntoTreeView();  
 
        //Add "All" to the top of the Tree View if needed  
        if (_UseAllOrg)  
        {  
            RadTreeNode all_node = new RadTreeNode("All""0");  
            RadTreeView1.Nodes.Insert(0, all_node);  
        }  
 
        //Set the selected node based on the SelectedOrgID -> This is fully implemented in ucOrgTreeViewDropDown.cs  
        if (_SelectedOrgID > -1)  
        {  
            bool nodeSelected = false;  
            foreach (RadTreeNode node in RadTreeView1.Nodes)  
            {  
                if (_SelectedOrgID == (Convert.ToInt32(node.Value)))  
                {  
                    node.Selected = true;  
                    nodeSelected = true;  
                    break;  
                }  
            }  
            if (!nodeSelected)  
            {  
                //Let the debugger know  
                System.Diagnostics.Debug.WriteLine("---");  
                System.Diagnostics.Debug.WriteLine("SelectedOrgID (" + _SelectedOrgID + ") was not found in the TreeView list. This could happen if the OrgID no longer exists in the Database or OrgID was removed from the TreeView due to the User's access rights.");  
                System.Diagnostics.Debug.WriteLine("---");  
            }  
        }  
 
        //Enable or disable the control  
        RadTreeView1.Enabled = _Enabled;  
    }  
 
    public int GetTopLevelID()  
    {  
        if(RadTreeView1.Nodes != null)  
            return Convert.ToInt32(RadTreeView1.Nodes[0].Value);  
        return -1;  
    }  
 
    public int GetIndexFromOrgID(int orgID)  
    {  
        RadTreeNode node = RadTreeView1.FindNodeByValue(orgID.ToString());  
        return node.Index;  
    }  
 
    private void RadTree_GenerateOrgHierarchies(List<Org> OrgList, bool ReducedList)  
    {  
        RadTreeView1.Nodes.Clear();  
        RadTreeNode nodes = new RadTreeNode();  
        if (!ReducedList || _RootOrgID == 0) //If _RootOrgID = 0 then show all Orgs  
        {  
            foreach (Org org in OrgList)  
            {  
                if (org.ParentOrgID == null//Found a top level org  
                {  
                    nodes = RadTree_GetAllChildern(OrgList, org, null);  
                    RadTreeView1.Nodes.Add(nodes);  
                }  
            }  
        }  
        else   
        {  
            nodes = RadTree_GetAllChildern(OrgList, OrgList[0], null);  
            RadTreeView1.Nodes.Add(nodes);  
        }  
    }  
 
    private RadTreeNode RadTree_GetAllChildern(List<Org> Orgs, Org pOrg, RadTreeNode pNode)  
    {  
        pNode = new RadTreeNode(pOrg.Name, pOrg.OrgID.ToString());  
        List<Org> childernList = bl.GetListOfChildern(pOrg.OrgID, Orgs);  
        foreach (Org org in childernList)  
        {  
            RadTreeNode cNode = RadTree_GetAllChildern(Orgs, org, pNode);  
            if(cNode.Nodes.Count == 0)  
                cNode = new RadTreeNode(org.Name, org.OrgID.ToString());  
            pNode.Nodes.Add(cNode);  
        }  
        return pNode;  
    }  
}  
 

The javascript file

The handlenodeclick method is where the selected node's text is placed into the drop down's text area. But for some reason when this happens on the first click, the drop down's text area is blank. But the backend still knows that the node is selected because when I select the search button for my application, it grabs that selected node's info to do the search. So some thing on setting up the drop down is not correct and I have played around with it for many hours trying to figure out why it is not working.

// Make sure the namespace is defined  
if (typeof(MyApp) == "undefined")  
    MyApp = {};  
if (typeof(MyApp.Controls) == "undefined")  
    MyApp.Controls = {};  
 
// Constructor  
MyApp.Controls.ucOrgTreeViewDropDown = function MyApp$Controls$ucOrgTreeViewDropDown(client_id, tree_client_id)  
{  
    this.ClientId = client_id;  
    this.TreeClientId = tree_client_id;  
      
    MyApp.Controls.ucOrgTreeViewDropDown.ObjectMap[client_id] = this;  
}  
 
MyApp.Controls.ucOrgTreeViewDropDown.ObjectMap = [];  
 
// static event handlers  
MyApp.Controls.ucOrgTreeViewDropDown.HandleNodeClicked = function MyApp$Controls$ucOrgTreeViewDropDown$HandleNodeClicked(sender, args)  
{  
    var combo_client_id = sender.get_attributes().getAttribute("ParentComboBoxID");  
    var comboBox = $find(combo_client_id);  
    var node = args.get_node();  
      
    comboBox.set_text(node.get_text());  
    comboBox.hideDropDown();  
}  
 
MyApp.Controls.ucOrgTreeViewDropDown.StopPropagation = function MyApp$Controls$ucOrgTreeViewDropDown$StopPropagation(e)  
{  
     if(!e)  
     {  
        e = window.event;  
     }  
     e.cancelBubble = true;  
}  
 
// member functions  
function MyApp$Controls$ucOrgTreeViewDropDown$GetSelectedOrgID()  
{  
    var org_tree_element = $find(this.TreeClientId);  
    if (org_tree_element == null)  
        return -1;  
    else 
        return org_tree_element.get_selectedNode().get_value();  
}  
 
function MyApp$Controls$ucOrgTreeViewDropDown$GetSelectedOrgName()  
{  
    var org_tree_element = $find(this.TreeClientId);  
    if (org_tree_element == null)  
        return -1;  
    else 
        return org_tree_element.get_selectedNode().get_text();  
}  
 
function MyApp$Controls$ucOrgTreeViewDropDown$SetSelectedOrgID(orgID)  
{  
    //debugger;  
    var comboBox = $find(this.ClientId);  
     
    comboBox.set_value(orgID);  
}  
 
// Prototype  
MyApp.Controls.ucOrgTreeViewDropDown.prototype =  
{  
    GetSelectedOrgID : MyApp$Controls$ucOrgTreeViewDropDown$GetSelectedOrgID,  
    GetSelectedOrgName : MyApp$Controls$ucOrgTreeViewDropDown$GetSelectedOrgName,  
    SetSelectedOrgID : MyApp$Controls$ucOrgTreeViewDropDown$SetSelectedOrgID  
}  
 

I hope I have supplied enough information to help in debugging this issue. Any help would be much appriciated.

I hope I have supplied enough information to help in debugging this issue. Any help would be much appriciated.

I hope I have supplied enough information to help in debugging this issue. Any help would be much appriciated.

I hope I have supplied enough information to help in debugging this issue. Any help would be much appriciated.

16 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 Apr 2008, 03:39 PM
Hello Andrew,

Have you followed the logic of our online example about TreeView in ComboBox? Everything is running as expected there. Please review the code. If it does not help you solve the problem, I believe that it would be best if you isolate it in a small and running project and attach the files to a new support thread. We will test your project files at our side and try to find a working solution for you.

Thanks for your time.

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andrew
Top achievements
Rank 1
answered on 08 Apr 2008, 04:36 PM
Hello Telerik,
that example I have looked at before. The problem with the example is that it does not have the drop drown text area pre-populated with a selected item. This is where the problem presents itself, which I explained in my tag. If you can make an example where the dropdown text area is pre-loaded with a selected node that works, that would be very helpful to see how you got that to work. Like I mentioned before if I do not pre-populate the dropdown text area, then selecting a node the first time does not fail to show up in the dropdown text area.
0
Nikolay
Telerik team
answered on 10 Apr 2008, 06:55 AM
Hi Andrew,

I tried to reproduce the logic by using our example. I simply set the Selected property of a node and tried to select it again. The input part of the combo was set accordingly. Since your code is quite complicated, can you reproduce the problem using our online example's logic and send us the steps to perform locally  so that the problem appears. Thus, we will be able to see the problem ourselves and try to locate its source.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andrew
Top achievements
Rank 1
answered on 15 May 2008, 08:49 PM

Since I was not able to attach any files for this post and was able to with support. I opened up a support ticket with the solution that was not working. They were able to direct me to the issue.

I was able to get the solution to work and added it to the support ticket 137210 for others to download and review and use as they wish.  I wish I could have been able to attach the solution to this posting but I did not see how I could do that. 

Anyway the issue ended up being the onclick event for the StopPropagation was not being rendered on the page even though that even was being set in the dropdown ascx page within the div's properties. What I had to do was place the setup of the div's onclick event in the constructor javascript method for it to be rendered on the page.  My guess the reason for this is because I am dealing with user controls.

Anyway thanks for you help.

0
Andreas Kaech
Top achievements
Rank 1
answered on 11 Aug 2008, 03:41 PM
Hi Telerik,
after successfully implementing your demo "Treeview in ComboBox",
I've now an issue with pre-populating the combobox with a selected TreeItem serverside. The Treeitem is selected but I have no success to show this item with:
combobox.Text = treenode.Text.
What does the trick?

Thanks for answering,
Andreas Kaech



0
Veselin Vasilev
Telerik team
answered on 11 Aug 2008, 03:51 PM
Hi Andreas Kaech,

Please set the AllowCustomText property of the combobox to True.

Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 13 Aug 2008, 04:03 AM
Hi Veskoni,

I have a similar problem - ie treeview in combo with custom text display.

My problem occurs however when the combo's initial text is an empty string ie:

cboTree.Text =

string.Empty

when a postback occurs and I subsequently update the combo's text value ie:

cboTree.Text =

"Some value" ;

the new text value is not displayed.

If the combo's initial text is not an empty string - the combo's text is updated as expected.

Regards, Michael.
0
Veselin Vasilev
Telerik team
answered on 13 Aug 2008, 06:56 AM
Hi Michael,

Can you please send us a sample project or at least paste here you code so we can debug it faster.

Thanks 

Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 14 Aug 2008, 02:14 AM
Hi Veskoni,

Here is a sample that displays the behaviour - aspx

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Testing._Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
 
    <div>     
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
    </div> 
      
 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script language="javascript" type="text/javascript">  
 
            function StopPropagation(e)    
            {    
                if(!e)    
                {    
                    e = window.event;    
                }    
         
                e.cancelBubble = true;                                   
            }    
                          
            function Save()  
            {                                  
                var ajaxPanel = $find("<%= RadAjaxManager.ClientID %>");  
                ajaxPanel.ajaxRequest('Save');  
 
                return false;  
            }             
 
        </script> 
    </telerik:RadCodeBlock> 
 
    <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" OnAjaxRequest="RadAjaxManager_AjaxRequest">  
 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="cboTree" />   
                </UpdatedControls>              
            </telerik:AjaxSetting>   
        </AjaxSettings>           
 
    </telerik:RadAjaxManager> 
 
    <table style="width:100%; height:100%">  
        <tr> 
            <td style="width:80%">  
                <telerik:RadComboBox ID="cboTree" runat="server" AllowCustomText="true"     
                    RadComboBoxImagePosition="Right" Skin="Office2007" Width="100%"   
                    ExpandAnimation-Duration="100" CollapseAnimation-Duration="100">  
                    <Items>                                    
                        <telerik:RadComboBoxItem runat="server"/>    
                    </Items>    
                    <CollapseAnimation Duration="100" Type="OutQuint" /> 
                    <ExpandAnimation Type="OutQuart" /> 
                    <ItemTemplate>                                       
                        <div id="div1" onclick="StopPropagation()">   
                            <telerik:RadTreeView ID="tvwTree" runat="server" Skin="Office2007" EnableViewState="true"                                                     
                                Width="100%" style="white-space:normal" MultipleSelect="true" ShowLineImages="False" CheckBoxes="True">  
                            </telerik:RadTreeView> 
                        </div>   
                    </ItemTemplate>   
                </telerik:RadComboBox> 
            </td> 
        </tr> 
        <tr> 
            <td>                              
                <hr /> 
                <input id="btnSave" type="button" value="Save"  onclick="return Save();return false;"/>                      
            </td> 
        </tr> 
    </table>   
    
    </form> 
</body> 
</html> 
 

Code behind:

using System;  
using System.Collections;  
using System.Configuration;  
using System.Text;   
using System.Data;  
using System.Linq;  
 
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
 
using Telerik.Web.UI;     
 
namespace Testing  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!Page.IsPostBack)  
            {  
                LoadTree();  
            }  
        }  
 
        private void LoadTree()  
        {  
            RadTreeView tvw = (RadTreeView)this.cboTree.Items[0].FindControl("tvwTree");  
 
            for (int i = 0; i < 10; i++)  
            {  
                RadTreeNode node = new RadTreeNode();  
                node.Text = i.ToString();  
                node.Value = i.ToString();  
                node.Checked = false;  
 
                tvw.Nodes.Add(node);  
            }  
              
            cboTree.Text = string.Empty;  
            //cboTree.Text = "Some text"; //-- This works              
        }  
          
        protected void RadAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)  
        {  
            cboTree.Text = "Some other text";  
        }  
    }  
}  
 

Regards, Michael.

0
Veselin Vasilev
Telerik team
answered on 18 Aug 2008, 03:12 PM
Hi Michael,

Please set the Text of the combo item to a space like this:

<telerik:RadComboBoxItem runat="server" Text=" "/>

I think this will fix the problem.

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 19 Aug 2008, 02:21 AM
Hi Veskoni,

Yes I am aware that setting the text to " " will workaround the problem - is this a bug with the combo, as this was not a problem in the previous release  ie Q3 2007.

Also, how can I make the combo text read only - if I use the AllowCustomText= "True" (which I need to to set the text), then the text box text containing the treeview becomes editable which again was not a problem in the previous release.

Regards, Michael.
0
Michael
Top achievements
Rank 1
answered on 19 Aug 2008, 04:42 AM
Hi Veskoni,

Sorry previous release should read - Q1 2008.

Regards, Michael.
0
Veselin Vasilev
Telerik team
answered on 22 Aug 2008, 07:10 AM
Hi Michael,

We are investigating the problem now and I hope we will fix it for the SP1 due to next week.

I have updated your Telerik Points for your involvement.

Thanks

Regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Austin McDaniel
Top achievements
Rank 1
answered on 08 Oct 2008, 02:24 PM
I just wanted to follow up with this issue and see if anyone had a resolution.  I am having the same issue and am eager to see if it has been resolved.

Also, I am having an issue with the ExpandAllNodes() method working on the treeview combobox control.  Any ideas?
0
KevinMc
Top achievements
Rank 1
answered on 17 Oct 2008, 06:30 PM
Austin:

I have used the following javascript function in the past when i was trying to expand all nodes. It was provided to me by telerik:

function OnCategoryDropDownOpeningHandler(sender, eventArgs)  
            {  
               var tree = $find('<%= comboCategories.Items[0].FindControl("treeCategories").ClientID %>');  
                  
               var nodes = tree.get_allNodes();  
                     
               for (var i = 0; i < nodes.length; i++)  
               {  
                   if (nodes[i].get_nodes() != null)  
                   {  
                       nodes[i].expand();  
                   }  
               }  
            } 

Add to Properties of comboboxOnClientDropDownOpening="OnCategoryDropDownOpeningHandler"

0
Rosi
Telerik team
answered on 20 Oct 2008, 06:53 AM
Hello Austin McDaniel,

I suggest you try our beta Q3 release build and let us know how it goes.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Andrew
Top achievements
Rank 1
Andreas Kaech
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Michael
Top achievements
Rank 1
Austin McDaniel
Top achievements
Rank 1
KevinMc
Top achievements
Rank 1
Rosi
Telerik team
Share this question
or