RadPanelItemCollection Object
The RadPanelItemCollection object is returned by the get_items method of the RadPanelBar or RadPanelItem object. The following table lists the most important methods.
Changes to the item collection made using these methods do not persist after a postback unless surrounded by a call to the trackChanges method of the panel bar object and the commitChanges method of the panel bar object.
Name | Parameters | Return Type | Description |
---|---|---|---|
add | RadPanelItem | none | Adds a child item to the end of the collection. See Example 1. |
insert | int,RadPanelItem | none | Inserts the item into the collection at the position specified by the first (index) parameter. See Example 2. |
remove | RadPanelItem | none | Removes the specified item from the collection. See Example 3. |
removeAt | int | none | Removes the item at the specified index. See Example 4. |
clear | none | none | Clears the Items collection of all the child items it contains. See Example 5. |
getItem | int | RadPanelItem | Returns the item from the collection that resides at the specified index. See Example 6. |
indexOf | RadPanelItem | int | Returns the index of an item. See Example 7. |
get_count | none | int | Returns the number of the items in the collection. See Example 8. |
function AddNewItem() {
var panelbar = $find("<%= RadPanelBar1.ClientID %>");
var panelItem = new Telerik.Web.UI.RadPanelItem();
panelItem.set_text("New Item");
panelbar.trackChanges();
panelbar.get_items().add(panelItem);
panelbar.commitChanges();
}
function InsertAtStart() {
var panelbar = $find("<%= RadPanelBar1.ClientID %>");
var panelItem = new Telerik.Web.UI.RadPanelItem();
panelItem.set_text("New Item");
panelbar.trackChanges();
panelbar.get_items().insert(0, panelItem);
panelbar.commitChanges();
}
function deleteItem() {
var panelbar = $find("<%= RadPanelBar1.ClientID %>");
var panelItem = panelbar.findItemByText("Paris");
if (panelItem) {
panelbar.trackChanges();
panelbar.get_items().remove(panelItem);
panelbar.commitChanges();
}
}
function removeLastItem() {
var panelbar = $find("<%= RadPanelBar1.ClientID %>");
var items = panelbar.get_items();
if (items.get_count() > 0) {
panelbar.trackChanges();
items.removeAt(items.get_count() - 1);
panel.commitChanges();
}
}
var panelBar = $find("<%= RadPanelBar1.ClientID %>");
panelBar.trackChanges();
panelBar.get_items().getItem(0).get_items().clear();
panelBar.commitChanges();
var panelBar = $find("<%= RadPanelBar1.ClientID %>");
var rootItem1 = panelBar.get_items().getItem(0);
var panelBar = $find("<%= RadPanelBar1.ClientID %>");
var item = panelBar.findItemByText("target");
if (item) {
var index = item.get_parent().get_items().indexOf(item);
}
var panelBar = $find("<%= RadPanelBar1.ClientID %>");
var items = panelBar.get_items();
for (var i = 0; i < items.get_count(); i++) {
alert(items.getItem(i).get_text());
}