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

Find control in ComboBox Item

7 Answers 214 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Evgeniy
Top achievements
Rank 1
Evgeniy asked on 16 Oct 2008, 12:06 PM
Hi,

I have on page RadComboBox with ItemTemplate:
<telerik:RadComboBox ID="ddlDestination" runat="server" DataSourceID="dsDestination" DataTextField="country" DataValueField="countryID" OnClientSelectedIndexChanged="ChangeItem"
<ItemTemplate> 
     <%#Eval("country") %> 
     <asp:TextBox ID="txtContinentId" runat="server" Visible="false" Text='<%# Eval("continentID")%>'></asp:TextBox> 
</ItemTemplate> 
<CollapseAnimation Duration="200" Type="OutQuint" /> 
</telerik:RadComboBox> 

and I have javascript function
<script language="javascript" type="text/javascript"
        function ChangeItem(sender, eventArgs) 
        {     
            var item = eventArgs.get_item(); 
            var txt = item.findControl("txtContinentId"); 
            alert (txt); 
            fmAreaCenter(item.get_value()); 
        } 
    </script> 

which fire when OnClientSelectedIndexChanged fired.
How get value TextBox of current Item?
var txt = item.findControl("txtContinentId");



is not find textbox!


7 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 16 Oct 2008, 12:58 PM
Hi Evgeniy,

Please use the following javascript code to find the textbox in RadComboBox item template:

 function ChangeItem(sender, eventArgs)    
      {      
         var item = eventArgs.get_item();    
         var txt = item.get_element().children[0];  
         alert(txt);  
      }  

Note that the textbox should be visible.

Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Evgeniy
Top achievements
Rank 1
answered on 16 Oct 2008, 02:33 PM
Thank you very much!!!

But my TextBox have visible=false!!!!!!!

that to do me?




Help me please.

Thanks!
0
Atanas Korchev
Telerik team
answered on 16 Oct 2008, 02:39 PM
Hi Evgeniy,

Server controls which have their Visible property set to false are not rendered at all. This means that you cannot get them on the client-side.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Evgeniy
Top achievements
Rank 1
answered on 16 Oct 2008, 02:56 PM
Thank you!

I have a following problem:
My RadComboBox binding with SqlDataSource.
In SqlDataSource i have 3 column: ContinentId, CountryId, CountryName.
In RadComboBox:
DataTextField = CountryName
DataValueField = CountryId
But I need to store ContinentId in RadComboBox too.

Can I make it?
0
Veselin Vasilev
Telerik team
answered on 16 Oct 2008, 03:10 PM
Hi Evgeniy,

You need to use CustomAttributes and ItemDataBound event.

I hope this will get you started.

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Datamex
Top achievements
Rank 2
answered on 26 Sep 2009, 12:39 PM
Hi,

The solution you gave :

function ChangeItem(sender, eventArgs)       
      {         
         var item = eventArgs.get_item();       
         var txt = item.get_element().children[0];     
         alert(txt);     
      }     
 

Only seems to work in internet explorer and not in firefox.
Is there a way to get the item also in firefox?
0
Yana
Telerik team
answered on 28 Sep 2009, 07:57 AM
Hi Datamex,

I'm sorry it should be like this:

function DoOnClientNodeExpanded(sender, eventArgs) { 
        eventArgs.get_node().select(); 
        CollapseOthers(eventArgs.get_node()); 
        return true
    } 

All the best,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Evgeniy
Top achievements
Rank 1
Answers by
Yana
Telerik team
Evgeniy
Top achievements
Rank 1
Atanas Korchev
Telerik team
Veselin Vasilev
Telerik team
Datamex
Top achievements
Rank 2
Share this question
or