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

Using $find in JS to find a RadComboBox

1 Answer 52 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vamshi
Top achievements
Rank 1
Vamshi asked on 08 Nov 2011, 11:00 PM
Hi, I am new to using telerik controls. I have been trying to write some javascript to add items to an existing radcombobox. Using examples in the demos I did something like this, to first of all get the existing combobox:

var combo = $find ("<%=RadComboBox1.ClientID%>");

however when I check combo, it is always null.

Any ideas what to do? Pl let me know if you need more info about my code.

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Nov 2011, 05:33 AM
Hello Vamshi,

Try the following javascript.
Javascript:
<script type="text/javascript">
 function Add()
 {
  var combo = $find("<%= RadComboBox1.ClientID %>");
  var newItem = new Telerik.Web.UI.RadComboBoxItem();
  newItem.set_text("Mario");
  combo.trackChanges();
  combo.get_items().add(newItem);
  comboItem.select();
  combo.commitChanges(); 
 }
 function OnClientItemChecked(sender,args)
 {
 alert(args.get_item().get_text());
 }
</script>
Please elaborate your scenario if it doesn't help.

Thanks,
Princy.
Tags
ComboBox
Asked by
Vamshi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or