Using $find in JS to find a RadComboBox

2 posts, 0 answers
  1. Vamshi
    Vamshi avatar
    17 posts
    Member since:
    Jul 2010

    Posted 08 Nov 2011 Link to this post

    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!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Nov 2011 Link to this post

    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.
Back to Top