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

Problem Disabling ComboBox

3 Answers 44 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bob Boffin
Top achievements
Rank 2
Bob Boffin asked on 25 May 2010, 07:19 PM
I wish to disable a combobox and all its items using client side script. I've read all the documentation about how I should do this but whenever I try to call the disable() method I get an error saying that the method does not exist.

I am getting the reference to the ComboBox by calling document.getElementById("<% = combo.ClientID %>") but I notice that in your examples you are using a function called $find which appears to be undocumented as I can find no description of it anywhere on the web.

If I try to use this instead of getElementByID it always returns null.

Please could you explain to me the difference between $find and getElementById and how I can get this to work.

I have tried enclosing the script in a RadScriptBlock but it made no difference.

I am using version 2008.3.1314.35 of the Rad Ajax Components

Bob Boffin

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 May 2010, 09:14 AM

Hello,

 

The difference between $get() and $find() is that $get() returns the DOM element with the ID you provide, and $find() returns the client-side component associated with the id you provide. This is a very big difference. When you made the call to $get(), you were given a reference to the <div> with the id combo.ClientID which contains the combo markup. Instead, a call to $find('<%= combo.ClientID %>') will return the JavaScript object which represents the RadComboBox and contains all of its client-side functionality.

Difference between $get and $find

 

You need to use the $find() method to get the client object of combobox. And call the disable() method for disabling the control.
Here are the links which shows most important client methods and properties of RadComboBox.
Client-Side Basics
RadComboBox object

Regards,
Princy.

0
Bob Boffin
Top achievements
Rank 2
answered on 26 May 2010, 09:49 AM
Thanks for the explanation. I now understand why I should be using $find but as I said whenever I use $find it returns null so what I now need is to find out why $find isn't working.

The script is in a user control that is a PageView associated with a TabStrip and the ComboBox is defined within this user control. Does this affect the scope of the $find? Can I only call $find in script in the .aspx owner page?

Regards

Bob Boffin
0
Veronica
Telerik team
answered on 26 May 2010, 06:59 PM
Hello Bob,

To be able to access Client-side functions as enable(), disable() etc. you'll need to use the $find() function. With it you can obtain a reference of the RadComboBox object.
 
If you write document.getElementById("RadComboBox1") you'll get the div tag in which the RadComboBox is located. It doesn't have any methods.

So the solution to disable the RadComboBox client-side is:

function pageLoad() {
           var combo = $find("<%= RadComboBox1.ClientID %>");
           combo.disable();
       }

Hope this helps.

Best Regards,
Veronica Milcheva
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
Bob Boffin
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Bob Boffin
Top achievements
Rank 2
Veronica
Telerik team
Share this question
or