RadControls for ASP.NET AJAX
The RadListBoxItemCollection object is returned by the get_items method of the RadListBox client object. The following table lists the most important methods:
Name | Parameters | Return Type | Description |
|---|
add | RadListBoxItem | none | Adds an item to the Items collection |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items(); list.trackChanges();
var item = new Telerik.Web.UI.RadListBoxItem();
item.set_text("New");
item.set_value("Value");
items.add(item);
list.commitChanges();
insert | int, RadListBoxItem | none | Inserts an item into the Items collection at the position specified by the first (index) parameter |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
list.trackChanges();
var item = new Telerik.Web.UI.RadListBoxItem();
item.set_text("New");
item.set_value("Value");
items.insert(0, item);
list.commitChanges();
remove | RadListBoxItem | none | Removes an item from the Items collection |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
var item = list.get_selectedItem();
list.trackChanges();
items.remove(item);
list.commitChanges();
clear | none | none | Clears the Items collection of RadListBox |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
items.clear();
getItem | index | RadListBoxItem | Gets the item from the Items collection residing at the index specified by the parameter. |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
var firstItem = items.getItem(0);
indexOf | RadListBoxItem | int | Gets the index of an item. |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
var index = items.indexOf(list.get_selectedItem());
removeAt | int | none | Removes the item at the specified index. |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
var index = items.indexOf(list.get_selectedItem());
items.removeAt(index);
get_count | none | int | Returns the number of items in the Items collection. |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
for (var i = 0; i < items.get_count(); i++) {
alert(list.getItem(i).get_text());
}
forEach | handler | none | Iterates through the Items collection |
CopyJavaScript
var list = $find("<%= RadListBox1.ClientID %>");
var items = list.get_items();
items.forEach(function (item) {
alert(item.get_text());
});
See Also