New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

RadComboBoxItemCollection Object

The RadComboBoxItemCollection object is returned by the get_items method of the RadComboBox object. The following table lists the most important methods:

 

NameParametersReturn TypeDescription
addRadComboBoxItemnoneAdds an item to the Items collection. See Example 1.
insertint, RadComboBoxItemnoneInserts an item into the Items collection at the position specified by the first (index) parameter. See Example 2.
removeRadComboBoxItemnoneRemoves a child item from the Items collection. See Example 3.
clearnonenoneClears the Items collection of RadComboBox. See Example 4.
getItemintRadComboBoxItemGets the item from the Items collection residing at the index specified by the parameter. See Example 5.
indexOfRadComboBoxItemintGets the index of an item. See Example 6.
removeAtintnoneRemoves the item at the specified index. See Example 7.
get_countnoneintReturns the number of items in the Items collection. See Example 8.

Example 1: Add an item to the Items collection.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items();
combo.trackChanges();
var comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text("New");
comboItem.set_value("Value");

items.add(comboItem); 
combo.commitChanges();
	

Example 2: Insert a new item into the Items collection at index 0.

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

combo.trackChanges();
var comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text("New");
comboItem.set_value("Value");
items.insert(0, comboItem); 
combo.commitChanges();
	

Example 3: Find an item by its text value and remove it from the Items collection.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items();
var comboItem = combo.findItemByText("Paris");
combo.trackChanges();
items.remove(comboItem); 
combo.commitChanges();
	

Example 4: Clear the Items collection.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items(); 
items.clear();
	

Example 5: Get the item at index 1 from the Items collection.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items();
//Gets the second item from the Items collection 
var comboItem = items.getItem(1);
	

Example 6: Find an item by its text value and get its index in the Items collection.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items();
var comboItem = combo.findItemByText("Paris"); 
var index = items.indexOf(comboItem);
	

Example 7: Remove the item at the specified index.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>"); 
var items = combo.get_items();
var comboItem = combo.findItemByText("Paris"); 
var index = items.indexOf(comboItem);
items.removeAt(index);
	

Example 8: Get the number of items in the Items collection and display their text value.

JavaScript
	
var combo = $find("<%= RadComboBox1.ClientID %>");
var items = combo.get_items(); 
for (i = 0; i < items.get_count(); i++) 
{
    alert(items.getItem(i).get_text());
}
	

See Also

In this article
See Also
Not finding the help you need?
Contact Support