RadComboBox get_text() Problem

4 posts, 0 answers
  1. Azadeh
    Azadeh avatar
    11 posts
    Member since:
    Mar 2012

    Posted 04 Aug 2012 Link to this post

    Hi, 
    i used Telerik Version 2011.3 and have a  problem when use get_text() in javascript. that retruns Empty in chrome.
    thanks,
    Azadeh
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 06 Aug 2012 Link to this post

    Hi Azadeh,

    The following definition and JavaScript related to RadComboBox works just fine at my end in all major browsers.
    function clicked(sender, args) {
        var combo = $find("RadComboBox1");
        alert(combo.get_text());
    }
    <telerik:RadComboBox runat="server" ID="RadComboBox1">
        <Items>
            <telerik:RadComboBoxItem Text="111" />
            <telerik:RadComboBoxItem Text="222" />
            <telerik:RadComboBoxItem Text="333" />
        </Items>
    </telerik:RadComboBox>
    <telerik:RadButton  runat="server" Text="click" AutoPostBack="false" OnClientClicked="clicked"/>

    The following help article referencing the client API of the control might be of help too: http://www.telerik.com/help/aspnet-ajax/combobox-client-side-basics.html.

    Kind regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Azadeh
    Azadeh avatar
    11 posts
    Member since:
    Mar 2012

    Posted 07 Aug 2012 Link to this post

    Hi,
    My source is here.

        <telerik:RadComboBox ID="RCB" AllowCustomText="true" MarkFirstMatch="true" OnItemsRequested="RCB_ItemsRequested"
            EnableLoadOnDemand="true" runat="server" AppendDataBoundItems="true" ShowWhileLoading="true"
            ZIndex="15000" OnClientSelectedIndexChanged="EP_AddB" OnClientBlur="EP_AddB">
        </telerik:RadComboBox>

    function EP_AddB(sender, args) {
            EP_Add(sender.get_id());
        }
        function EP_Add(nam) {
            var commID = nam.toString().substring(0, nam.toString().length - 4);
            $get(commID + '_LB1').options.add(new Option($find(nam).get_text(), $find(nam).get_value()));
            EP_Copy2HF($get(commID + '_HF1'), $get(commID + '_HF2'), $get(commID + '_LB1'));
            $find(nam).set_text('');
        }
    In EP_AddB(sender, args) function get_id() returns value but in EP_Add(nam) get_text() returns Empty.
    and this problem only occurs in Chrome.
    can u check this please and let me know your idea?
    thanks,
    Azadeh
  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 07 Aug 2012 Link to this post

    Hi Azadeh,

    This has to do with the load-on-demand functionality and the RadComboBox not being able to find an item that matches the text typed in the input area.
    You could, however, try the following approach:
    function blur(sender, args) {
        alert(sender.get_text());
    }
    <telerik:RadComboBox ID="RCB" AllowCustomText="True" MarkFirstMatch="True"
        EnableLoadOnDemand="True" runat="server" AppendDataBoundItems="True"
        ZIndex="15000" OnClientSelectedIndexChanged="EP_AddB" OnClientBlur="blur"
        DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID">
    </telerik:RadComboBox>

    I hope this will help.

    Regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top