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

RadComboBox get_text() Problem

3 Answers 151 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Azadeh
Top achievements
Rank 1
Azadeh asked on 04 Aug 2012, 05:16 AM
Hi, 
i used Telerik Version 2011.3 and have a  problem when use get_text() in javascript. that retruns Empty in chrome.
thanks,
Azadeh

3 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 06 Aug 2012, 03:23 PM
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.
0
Azadeh
Top achievements
Rank 1
answered on 07 Aug 2012, 06:57 AM
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
0
Ivana
Telerik team
answered on 07 Aug 2012, 02:00 PM
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.
Tags
ComboBox
Asked by
Azadeh
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Azadeh
Top achievements
Rank 1
Share this question
or