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

[Solved] Problem setting text to RadComboBox

2 Answers 129 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dario Zanelli
Top achievements
Rank 1
Dario Zanelli asked on 17 Dec 2009, 11:22 AM
Hi all,
I have a problem using the SetText() and ClearSelection() function over a RadCombobox control, using javascript for client side execution of the code.
Probably the code explains better than words:
My controls are:

                     <td>
                            <telerik:RadComboBox ID="cmbStato" runat="server" EmptyMessage="Insert control form status..."
                                DataTextField="Description" DataValueField="Id" Filter="Contains"
                                AllowCustomText="true" DataSourceID="LinqDataSourceStato">
                            </telerik:RadComboBox>
                        </td>
                        <td width="18" style="padding-left: 5px;">
                            <asp:ImageButton ID="imgClearStatus" runat="server" AlternateText="Clear selection"
                            ImageUrl="_LAYOUTS/IMAGES/Iacopo/eliminaOn.gif" OnClientClick="ImgClearClick(this.getAttribute('id'))"
                             Width="14" Height="14"/>
                        </td>

When I click on the ImageButton I want to clear the content of the ComboBox. Here following my javascript code:

function ImgClearClick(item) {
   var combo = $find("<%= cmbStato.ClientID %>");
   //combo.disable(); //WORKS!!
   combo.SetText(''); //DOESN'T WORK
   combo.ClearSelection(); //DOESN'T WORK
   // var str = combo.GetValue(); //DOESN'T WORK
}

I also put commented tests I have done that were working or not. In particular the disable/enable funcions work properly.

Thanks in advance for any help you can give me.

Regards,

Dario Zanelli

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2009, 12:10 PM
Hello Dario Zanelli,

I guess you are referring the documentation for 'RadControls for ASP.NET version'. Try the following code and see whether it is working fine.

javascript:
 
    function ImgClearClick(item) { 
        var combo = $find("<%= cmbStato.ClientID %>"); 
        combo.disable(); 
        combo.set_text('');  
        combo.clearSelection();  
        var str = combo.get_value();  
    } 

Here is the documentation for 'RadControls for ASP.NET AJAX version'.
RadComboBox object

-Shinu.
0
Dario Zanelli
Top achievements
Rank 1
answered on 17 Dec 2009, 02:26 PM
Hello Shinu!
You were right! The problem was actually that.
Now everything works properly.

Thanks a lot for your prompt and accurate answer.

Dario Zanelli
Tags
ComboBox
Asked by
Dario Zanelli
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dario Zanelli
Top achievements
Rank 1
Share this question
or