IMG-LOGO

Telerik RadComboBox Client Side Javascript

andy - 02 Dec, 2014 16794 Views 1 Comment

How to get an object of RadComboBox using Javascript

To get an object of radcombobox, you will firstly need to know the client id of the object. You can use the following javascript code:

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

How to get an item of RadComboBox using Javascript

Firstly you need to get an object of radcombobox, once the instance has been found you can use method findItemByText or findItemByValue.

var combo = $find("<%= ComboBox.ClientID %>");
var itemByText = combo.findItemByText(text);
var itemByValue = combo.findItemByValue(text);

How to disable radcombobox using Javascript

To disable the radcombobx you can using a method named disable() or enable()

var combo = $find("<%= ComboBox.ClientID %>");
//To enable the combo box
combo.enable();

//To disable the combo box
combo.disable();

How to get or set a value form radcombobox using Javascript

//To get the value
var combo = $find("<%= ComboBox.ClientID %>");
var value = combo.get_value();

//To set the value by using value
var combo = $find("<%= ComboBox.ClientID %>");
combo.findItemByValue("value").select();

//To set the value by using text
combo.findItemByText("text").select();

How to clear combo selection item?

//To get the value
var combo = $find("<%= ComboBox.ClientID %>");
combo.clearSelection(); 

How to get a number of items of a radcombobox?

var combo = $find("<%= ComboBox.ClientID %>");
console.log(combo.get_items().get_count());

How to add an item into a radcombobox?

var combo = $find("<%= ComboBox.ClientID %>");
comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text("United States");
comboItem.set_value("USA");
combo.get_items().add(comboItem);
combo.commitChanges();

Comments

JC
25 Mar, 2022
How do we append items after certain index?
Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Articles