can get custom properties of ineheritated radcombobox in javascript

7 posts, 0 answers
  1. Elisabeth
    Elisabeth avatar
    8 posts
    Member since:
    Nov 2012

    Posted 08 Jan 2013 Link to this post

    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!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Elisabeth
    Elisabeth avatar
    8 posts
    Member since:
    Nov 2012

    Posted 10 Jan 2013 Link to this post

    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



  5. Elisabeth
    Elisabeth avatar
    8 posts
    Member since:
    Nov 2012

    Posted 14 Jan 2013 Link to this post

    Can anyone help me?

    Thanks
  6. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 15 Jan 2013 Link to this post

    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
  7. Elisabeth
    Elisabeth avatar
    8 posts
    Member since:
    Nov 2012

    Posted 18 Jan 2013 Link to this post

    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
  8. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 21 Jan 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017