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

RadComboBox custom attributes

3 Answers 482 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin Donahue
Top achievements
Rank 1
Kevin Donahue asked on 10 Sep 2010, 02:18 AM
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?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Sep 2010, 02:34 PM
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.
0
Kalina
Telerik team
answered on 14 Sep 2010, 11:21 PM
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
0
Kevin Donahue
Top achievements
Rank 1
answered on 29 Sep 2010, 03:01 AM
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
Tags
ComboBox
Asked by
Kevin Donahue
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kalina
Telerik team
Kevin Donahue
Top achievements
Rank 1
Share this question
or