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

RadTreeView in RadCombobox give me trouble in Version:2010.2.713.35 but not in previous version

2 Answers 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
simon
Top achievements
Rank 1
simon asked on 06 Aug 2010, 12:04 AM
 I am upgrading a asp.net project from older telerik RadContorls (2008.03.1125.35) to (2010.2.713.35).

I have a RadComboBox + RadTreeView inside.

proper behavior (which was working perfectly in the old version):
=========================
Click the inside treeview node;
Javascript update ComboBox value;
postback
ComboBox lost focus after postback;
========================

Weired behavior after new RAD version
========================
First time load the page and click the inside treeview node,
Javascript update CobmoBox  value;
No postback & ComboBox not losing focus; (Until I click any blank area of the page, it posts back and losing focus for ComboBox)

Once the first time done (clicking the blank area),
ComboBox turns normal behavior for the rest treeview node changes (no need to click blank area to postback).
==========================

My code is here:
==============
Javascript
---------------------------------------
function nodeClicking(sender, args)
{
           
    var comboBox = $find('<%= RadCboOffice.ClientID %>');
    
    var node = args.get_node()
    if(node.get_value()!='no')
    {
        comboBox.set_text(node.get_text());
        CollapseAllNodes();
        comboBox.hideDropDown();
    }
    else
    {
        node.expand();
        //no further postback needed
        event.cancelBubble = true;
    }
}

function CollapseAllNodes()
{
   var tree = $find('<%=RadCboOffice.Items[0].FindControl("RadTrvOffice").ClientID %>');;
            
   var allNodes = tree.get_allNodes();
   
   var index;
   for (index = 0; index < allNodes.length; index++)
   {
       var node = allNodes[index];
       if(node.get_expanded())
       {
           node.collapse();
       }
   }
   
}
-------------------------------------
ASPX
        <telerik:RadComboBox ID="RadCboOffice" Runat="server" Width="300px"  CssClass="" OnClientLoad="CboLoad" Skin="WebBlue" AutoPostBack="true" OnTextChanged="RadCboOffice_TextChanged">
        <ItemTemplate>
        <div id="div1">
        <telerik:RadTreeView runat="server" ID="RadTrvOffice"  ShowLineImages="false" OnClientNodeClicking="nodeClicking"/>
        </div>
        </ItemTemplate>
        <Items>
        <telerik:RadComboBoxItem runat="server" />
        </Items>
        </telerik:RadComboBox>   
---------------------------------------
code behind C#

        protected void RadCboOffice_TextChanged(object sender, EventArgs e)
        {
            TxtHiddenOfficeId.Text = GetOfficeId().ToString();
        }

----------------------------------------
Again, this is very weird to me. Old version works, new version will only hiccup for the first time.

Please help.

Thanks a lot
-Simon

2 Answers, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 06 Aug 2010, 02:01 PM
Hello simon,

RadComboBox' current behavior is to retain the focus in itself after selection. You can see this behavior in all of our demos. Most likely we have fixed this at some point since Q3 2008.

What was curious during my test was the even when I used your code the RCB did not postback unless I clicked somewhere outside it even after the first postback.

In any case, you can still force a postback with the following code:
var command = { Command: "TextChanged" };
comboBox.postback(command);

I hope this helps.

Kind regards,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
simon
Top achievements
Rank 1
answered on 06 Aug 2010, 05:03 PM
Thanks for the tip.

It really helped .

My code end up changing like this, and it works now.

Javascript
===========
function nodeClicking(sender, args)
{

    var command = { Command: "TextChanged" };            
    var comboBox = $find('<%= RadCboOffice.ClientID %>');
    
    var node = args.get_node()
    
    if(node.get_value()!='no')
    {
    comboBox.set_text(node.get_text());
    CollapseAllNodes();
    comboBox.hideDropDown();
    comboBox.postback(command);
    }
    else
    {
        node.expand();
        
        //no further postback needed
        event.cancelBubble = true;
    }
}

aspx declaration change (very important to fix the issue)
================
        <telerik:RadComboBox ID="RadCboOffice" Runat="server" Width="300px"  CssClass="" OnClientLoad="CboLoad" Skin="WebBlue" AutoPostBack="true" OnTextChanged="RadCboOffice_TextChanged">
        <ItemTemplate>
        <div id="div1">
        <telerik:RadTreeView runat="server" ID="RadTrvOffice"  ShowLineImages="false" OnClientNodeClicked="nodeClicking" />
        </div>
        </ItemTemplate>
        <Items>
        <telerik:RadComboBoxItem runat="server" />
        </Items>
        </telerik:RadComboBox>           
====================
As you can see OnClientNodeClicking (before) ----> OnClientNodeClicked


Tags
ComboBox
Asked by
simon
Top achievements
Rank 1
Answers by
Simon
Telerik team
simon
Top achievements
Rank 1
Share this question
or