Find control in ComboBox Item

8 posts, 0 answers
  1. Evgeniy
    Evgeniy avatar
    17 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2008 Link to this post

    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!


  2. Yana
    Admin
    Yana avatar
    4357 posts
    Member since:
    Sep 2012

    Posted 16 Oct 2008 Link to this post

    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.

  3. DevCraft Release
  4. Evgeniy
    Evgeniy avatar
    17 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2008 Link to this post

    Thank you very much!!!

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

    that to do me?




    Help me please.

    Thanks!

  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8255 posts
    Member since:
    Sep 2012

    Posted 16 Oct 2008 Link to this post

    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.

  6. Evgeniy
    Evgeniy avatar
    17 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2008 Link to this post

    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?

  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts
    Member since:
    Jul 2012

    Posted 16 Oct 2008 Link to this post

    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.

  8. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 26 Sep 2009 Link to this post

    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?

  9. Yana
    Admin
    Yana avatar
    4357 posts
    Member since:
    Sep 2012

    Posted 28 Sep 2009 Link to this post

    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.

Back to Top
DevCraft Release