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

Disable a RAD combo box using javascript

6 Answers 151 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
saravanan k
Top achievements
Rank 1
saravanan k asked on 05 Jun 2010, 01:20 PM
hi,

I have a asp:Button. OnCLientClick of the button, I call a javascript method-> Test()

function Test()
{
document.getElementById('Id of the combo box').disabled=true;
}

I am unable to do so. Please advice on how to proceed.

Thanks,
Saravanan

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 05 Jun 2010, 01:27 PM
Hello Saravanan,

Use the folowing code in order to disable the ComboBox.

Client Code:
var combo = $find("<%= ComboBox1.ClientID %>");   
combo.disable();  

You can also refer following link to online documentation which explains client side methods of combo.
Client-Side Basics

Regards,
Princy.
0
David Simmonds
Top achievements
Rank 1
answered on 22 Oct 2010, 06:00 PM
enable() and disable() are invalid methods for a RadComboBox.

This does not work:

 

 

var cb = document.getElementById("<%= RadComboBoxBIN.ClientID %>");

 

cb.enable();


I have to use document.getElementById because $find returns null.

Why can I not use enable()/disable() now? What do I use instead?

This also does not enable or disable the combobox. It does not cause an error like enable()/disable() does but it has no effect.

document.getElementById(

 

"<%= RadComboBoxBIN.ClientID %>").disabled = false;

 


document.getElementById(

 

"<%= RadComboBoxBIN.ClientID %>").disabled = true;

Does anyone have any ideas?

 

0
Cori
Top achievements
Rank 2
answered on 22 Oct 2010, 06:20 PM
Hello David,

If you are trying to disable it when the page loads. I assume you are trying to disable/enable when the page loads, if you get null from $find. You would have to do this to disable the RadComboBox:

Sys.Application.add_load(DisableRadComboBox);
  
function DisableRadComboBox()
{
   var combo = $find("<%=RadComboBox1.ClientID%>");
   combo.disable();
}

You would create another one that would do the reverse.

I hope that helps.
0
David Simmonds
Top achievements
Rank 1
answered on 25 Oct 2010, 07:22 PM
I tried using the documented enable() and disable() methods but when I run the code and I try to use enable() or disable() I get an error indicating that those methods are not valid. Why is this? The methods are documented. http://www.telerik.com/help/aspnet-ajax/combo_clientsideradcombobox.html
0
David Simmonds
Top achievements
Rank 1
answered on 25 Oct 2010, 07:41 PM
Turns out you have to use $find and not document.getelementbyid to get the full api of the object.
0
Kalina
Telerik team
answered on 26 Oct 2010, 12:22 PM
Hi David Simmonds,

The document.getElementById returns a DOM object, and $find returns the AJAX control client-side object.

I will recommend you use $find to get the RadComboBox client-side object, and after that use the enable() and disable() functions.
Please find more details about RadComboBox client-side methods and properties here.

Greetings,
Kalina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
saravanan k
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
David Simmonds
Top achievements
Rank 1
Cori
Top achievements
Rank 2
Kalina
Telerik team
Share this question
or