RadControls for ASP.NET AJAX
The RadToolBarItemCollection object is returned by the get_items method of the RadToolBar object. The following table lists the most important methods.
Caution |
|---|
RadToolBar's items can contain Buttons, DropDowns and SplitButtons. Each DropDown and SplitButton has its Buttons collection so that buttons can be added to these collections.
|
Note |
|---|
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 toolbar object and the commitChanges method of the toolbar object.
|
| Name | Parameters | Return Type | Description |
|---|
| add | RadToolBarItem | none | Adds a child item to the collection. |
CopyJavaScript
var toolBar = $find("<%=RadToolBar1.ClientID %>");
var button1 = new Telerik.Web.UI.RadToolBarButton();
button1.set_text("New Button1");
toolBar.trackChanges();
var dropDown = new Telerik.Web.UI.RadToolBarDropDown();
dropDown.set_text("DropDown");
var dropDownButton = new Telerik.Web.UI.RadToolBarButton();
dropDownButton.set_text("button1");
dropDown.get_buttons().add(dropDownButton);
var splitButton = new Telerik.Web.UI.RadToolBarSplitButton();
splitButton.set_text("Split Button");
var splitChildButton = new Telerik.Web.UI.RadToolBarButton();
splitChildButton.set_text("button1");
splitButton.get_buttons().add(splitChildButton);
toolBar.get_items().add(button1);
toolBar.get_items().add(dropDown);
toolBar.get_items().add(splitButton);
toolBar.commitChanges();
| insert |
int, RadToolBarItem | none | Inserts the item into the collection at the position defined by the first (index) parameter. |
CopyJavaScript
toolBar.trackChanges();
var insertButton = new Telerik.Web.UI.RadToolBarButton();
insertButton.set_text("Inserted Button");
toolBar.get_items().insert(0,insertButton);
var insertDropDown = new Telerik.Web.UI.RadToolBarDropDown();
insertDropDown.set_text("Inserted DropDown");
var dropDownButton = new Telerik.Web.UI.RadToolBarButton();
dropDownButton.set_text("button1");
insertDropDown.get_buttons().add(dropDownButton);
toolBar.get_items().insert(0, insertDropDown);
toolBar.commitChanges();
| remove | RadToolBarItem | none | Removes the specified item from the collection. |
CopyJavaScript
var firtItem = toolBar.get_items().getItem(0);
toolBar.trackChanges();
toolBar.get_items().remove(firtItem);
toolBar.commitChanges();
| clear | none | none | Clears the Items collection of all the child items it contains. |
CopyJavaScript
toolBar.trackChanges();
toolBar.get_items().clear();
toolBar.commitChanges();
| getItem | int | RadToolBarItem | Returns the item from the collection that resides at the specified index. |
CopyJavaScript
var firtItem = toolBar.get_items().getItem(0);
CopyJavaScript
var item = toolBar.get_items().getItem(0);
toolBar.get_items().indexOf(item);
| removeAt | int | none | Removes the item at the specified index. |
CopyJavaScript
toolBar.get_items().removeAt(0);
| get_count | none | int | Returns the number of the items in the collection. |
CopyJavaScript
toolBar.get_items().get_count();
See Also