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

Object doesn't support this property or method

4 Answers 216 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sean Severson
Top achievements
Rank 1
Sean Severson asked on 25 Sep 2009, 04:51 PM

I have a form with two RadComboBoxes.  One contains a list of states and the other contains a list of counties.  Basically, this is a cascading droplist scenario.  The OnClientSelectedIndexChanged event on the States RadComboBox is set to ChildRadComboChange shown below.  To populate the Counties RadComboBox when a state is selected, I run a LoadCounties method that is triggered by the State.ItemsRequested event.  So far, so good.

The problem comes in when the ChildRadComboLoad function runs (shown below).  The line childCombo.ClearItems() throws a Microsoft JScript runtime error: Object doesn't support this property or method.  The childID contains a valid control id and the childCombo variable is set to the correct RadComboBox (the div, actually).

Any ideas why I can't run this function on the RadComboBox?  I have also seen this with some of the other functions like RequestItems?

----Javascript functions

function ChildRadComboChange(sender, eventArgs) {
  var item = eventArgs.get_item();
  ChildRadComboLoad(sender, item);
}

function ChildRadComboLoad(sender, item) {
  var childID = ChildRadComboArray[sender.get_id()];
  var childCombo = document.getElementById(childID);
  childCombo.ClearItems();
  if (item.get_index() > 0) {    
   childCombo.RequestItems(item.get_value(),false);    
   childCombo.set_text('');}
  else {    
   childCombo.disable();    
   childcombo.set_text(ChildRadComboArray[sender.get_id()+'_msg']);
  }
}

Sincerely,

Sean M. Severson

4 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 26 Sep 2009, 11:38 AM
Hi Sean Severson,

Please specify which version of RadComboBox you are using. It seems you are mixing the names of the methods. For example: RequestItems is a method of the "classic" combobox while set_text() is a method of RadComboBox for ASP.NET Ajax.

This is how the method should look like if you use the newer RadComboBox:

function ChildRadComboLoad(sender, item) { 
  var childID = ChildRadComboArray[sender.get_id()]; 
  var childCombo = $find(childID); 
  childCombo.clearItems()
  if (item.get_index() > 0) {     
   childCombo.requestItems(item.get_value(),false);     
   childCombo.set_text('');} 
  else {     
   childCombo.disable();     
   childcombo.set_text(ChildRadComboArray[sender.get_id()+'_msg']); 
  } 


All the best,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sean Severson
Top achievements
Rank 1
answered on 28 Sep 2009, 12:56 PM
Veselin,

I am using the RadComboBox for ASP.NET Ajax, and your suggested changes solved the problem.  Thanks for the help.

Sean M. Severson
0
Sean Severson
Top achievements
Rank 1
answered on 28 Sep 2009, 06:05 PM
Just wanted to share a little bit of my experience at the risk of my embarassment...

$find and document.getElementById are not the same and cannot be used interchangeably.   Part of the problem I was experiencing is that I had an array of control id's which is a list of controls I want to enable or disable (as well as do some other actions on the radcombobox).  If I used $find, I could find the radcombobox control, but not the textbox controls.  If I used document.getElementById, I could get all of the controls, but could not utilize the radcombobox methods and properties (I was told that the object does not support this property or method).

My work around was to use $get (shortcut for document.getElementById) to get the controls and then perform a check on the className property to see if we had a radComboBox.  If yes, then I used $find to get the radCombobox and could then use the methods and properties I needed. 

I'm sure there is a cleaner way to do this and would love to hear about it.


Sincerely,

Sean M. Severson
0
Veselin Vasilev
Telerik team
answered on 29 Sep 2009, 05:23 AM
Hello Sean Severson,

Yes, you are right - $find finds the client (javascript) object while $get finds the DOM element.

All RadControls have client objects and you need to use the $find method to get these. The standard HTML elements (like input, button) on the contrary does not provide client objects so you need to use $get for these.

Sincerely yours,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Sean Severson
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Sean Severson
Top achievements
Rank 1
Share this question
or