RadToolBar for ASP.NET AJAX

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.

 
NameParametersReturn TypeDescription
addRadToolBarItemnoneAdds a child item to the collection.

CopyJavaScript
        var toolBar = $find("<%=RadToolBar1.ClientID %>");

        //create a new Button
        var button1 = new Telerik.Web.UI.RadToolBarButton();
        button1.set_text("New Button1");

        //create a new DropDown containing one child button
        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);

        //create a new SplitButton containing one child button
        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, RadToolBarItemnoneInserts 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();

 
removeRadToolBarItemnoneRemoves the specified item from the collection.

CopyJavaScript
        var firtItem = toolBar.get_items().getItem(0);
        toolBar.trackChanges();
        toolBar.get_items().remove(firtItem);
        toolBar.commitChanges();

 
clearnonenoneClears the Items collection of all the child items it contains.

CopyJavaScript
        toolBar.trackChanges();
        toolBar.get_items().clear();
        toolBar.commitChanges();

 
getItemintRadToolBarItemReturns the item from the collection that resides at the specified index.

CopyJavaScript
    var firtItem = toolBar.get_items().getItem(0);

 
indexOfRadToolBarItemintReturns the index of an item.

CopyJavaScript
    var item = toolBar.get_items().getItem(0);
    toolBar.get_items().indexOf(item);

 
removeAtintnoneRemoves the item at the specified index.

CopyJavaScript
    //the code below will remove the first item in the collection

    toolBar.get_items().removeAt(0);

 
get_countnoneintReturns the number of the items in the collection.

CopyJavaScript
    toolBar.get_items().get_count();

See Also