RadComboBox custom attributes

4 posts, 0 answers
  1. Kevin Donahue
    Kevin Donahue avatar
    33 posts
    Member since:
    Oct 2009

    Posted 09 Sep 2010 Link to this post

    Is it possible to store an attribute to the combo box instead of each item?  What I want to do is that when the SelectedItem is changed to update a different control.  I can't use find(<% %>) because my combobox is part of a user control and the control I want to update is part of a separate user control.

    Any suggestions?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Sep 2010 Link to this post

    Hi,


    I suppose you want to set the attribute to RadComboBox from code behind and retrieving in client side. If so, the follwoing code will help you to achieve the same.

    Adding attribute in code behind:
    RadComboBox5.Attributes.Add("key","attribute value");


    Retrieving the attribute:
    function getAttr() {
        var combo = $find("<%=RadComboBox5.ClientID %>");
        var value = combo.get_attributes().getAttribute("key");
        alert(value);
    }


    Thanks,
    Princy.
  3. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 14 Sep 2010 Link to this post

    Hello Kevin Donahue,

    You can obtain the client-side object of RadComboBox nested in user control if you add a global client-side variable to hold this object. Then handle the RadComboBox OnClientLoad event in this manner:
    <telerik:RadComboBox ID="RadComboBox1" runat="server"
        OnClientLoad="OnClientLoadHandler">
        <Items>
            <telerik:RadComboBoxItem Text="test1" Value="1" />
            <telerik:RadComboBoxItem Text="test2" Value="2" />
            <telerik:RadComboBoxItem Text="test3" Value="3" />
        </Items>
    </telerik:RadComboBox>

    <script type="text/javascript">
        var comboBox;
     
        function OnClientLoadHandler(sender) {
            comboBox = sender;
        }
     
    </script>

    After that you will be able to get the RadComboBox selected value at client-side and use it to update the other controls.
    I hope this helps.

    Greetings,
    Kalina
    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
  4. Kevin Donahue
    Kevin Donahue avatar
    33 posts
    Member since:
    Oct 2009

    Posted 28 Sep 2010 Link to this post

    Thanks Princy, that was pretty much what I was after.  For some reason I thought I had tried that.  Can I do something similar for the RadDatePicker?  I want to add an attribute, but I'm not sure how to find it client side.  It doesn't seem to have a "get_attributes" method.

    [EDIT] Nevermind.  I just found my answer here:
    http://www.telerik.com/community/forums/aspnet-ajax/calendar/access-custom-attributes-in-javascript.aspx
Back to Top