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

can get custom properties of ineheritated radcombobox in javascript

6 Answers 284 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Elisabeth
Top achievements
Rank 1
Elisabeth asked on 08 Jan 2013, 04:25 PM
Hi,

Sorry, the title should say "Cannot" instead of "Can" :)

I am using a custom combobox which inheritates from the RadComboBox. I have added some public properties which are

[PersistenceMode(PersistenceMode.Attribute)]


I need to access these custom properties from a javascript function called from the OnClientBlur client side event. Unfortunately they are not acessible. I must be missing something very obvious but I am stuck as some code in this function must only be performed depending on the values of these properties. How can I achieve that?

Thank you for your help!

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jan 2013, 05:32 AM
Hi,

I suppose you want to retrieve the attributes of RadComboBox from the client side. Try the following code snippet.

C#:
RadComboBox1.Attributes.Add("key", "attribute value");

JS:
<script language="javascript" type="text/javascript">
    function OnClientBlur(sender, args) {
        var value = sender.get_attributes().getAttribute("key");
        alert(value);
    }
</script>

Please take a look into this documentation for more information.

Regards,
Princy.
0
Elisabeth
Top achievements
Rank 1
answered on 10 Jan 2013, 02:56 PM
Hi,

thanks for your help.

Unfortunately, I don't know what I'm doing wrong but it is not working.

I have the following definition for my dropdown.
<stm:STMRadComboBox ID="ComboChefCC" runat="server" Width="100%"
                                    DataTextField="NomMatricule" DataValueField="No_Empl" ZIndex="7001" EmptyMessage="- nom ou matricule -"                   
                                    ShowToggleImage="true" MarkFirstMatch="true"
                                    EnableLoadOnDemand="True" ItemsPerRequest="10" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                                    OnItemsRequested="ComboChefCC_ItemsRequested" OnClientBlur="ClearComboCustomTextOnBlur2" IsForcedOnFirstItem="true">
</stm:STMRadComboBox>


and I am using what you suggested to retrieve the attributes .

function ClearComboCustomTextOnBlur2(sender, eventArgs) {
    var value = sender.get_attributes().getAttribute("ShowToggleImage");       
}


I tried different attributes but value is always undefined wether the attribute is custom or not.

For testing purposes I also tried to retrieve the index of the selected item using

var index = eventArgs.get_item().get_index();


but I get an error saying that the object doesn't manage the property or method "get_item". (sorry the message is in French and probably doesn't translate properly)

Am I doing something wrong?

Thanks



0
Elisabeth
Top achievements
Rank 1
answered on 14 Jan 2013, 01:01 PM
Can anyone help me?

Thanks
0
Cat Cheshire
Top achievements
Rank 1
answered on 15 Jan 2013, 12:46 PM
ShowToggleImage is a combobox property - it is not a combobox Item Attribute.
If you want to access an Item attribute - you have to set it.
I suppose that this article will help you: http://www.telerik.com/help/aspnet-ajax/combobox-custom-attributes.html
0
Elisabeth
Top achievements
Rank 1
answered on 18 Jan 2013, 06:50 PM
thanks for your reply.

I must be missing something.

I have a custom dropdown inheritating from the radComboBox. It has some custom properties set from code-behind. I need to access these properties from javascript, do some process and set some of them. Unfortunately, I don't seem to be able to acess them from javascript.

Is there a way of doing it?

Thanks again
0
Kevin
Top achievements
Rank 2
answered on 21 Jan 2013, 03:32 PM
Hello Elisabeth,

If you refer to Princy's initial post, that is how you get properties to appear on the client, in order to be able to access it using javascript.

I hope that helps.
Tags
ComboBox
Asked by
Elisabeth
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Elisabeth
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Share this question
or