RadToolBar for ASP.NET AJAX

RadControls for ASP.NET AJAX

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.

The RadToolBarButtonCollection object is returned by the get_buttons method of the RadToolBarDropDown or the RadToolBarSplitButton objects.The following table lists the most important methods.

Note

Changes to the button collection made using these methods do not persist after a postback unless surrounded by a call to the trackChanges and the commitChanges methods of the toolbar object.

 
NameParametersReturn TypeDescription
addRadToolBarButtonnoneAdds a child button to the collection.

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

    //creates 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);

    //creates 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(dropDown);
    toolBar.get_items().add(splitButton);
    toolBar.commitChanges();

 
insertint, RadToolBarButtonnoneInserts the button into the collection at the position defined by the first (index) parameter.

CopyJavaScript
    toolBar.trackChanges();
    var dropDown = new Telerik.Web.UI.RadToolBarDropDown();
    dropDown.set_text("DropDown");
    var dropDownButton = new Telerik.Web.UI.RadToolBarButton();
    dropDownButton.set_text("button1");

    //inserts a new button at index 0 of the dropDown's Buttons collection
    dropDown.get_buttons().insert(0, dropDownButton);
    var splitButton = new Telerik.Web.UI.RadToolBarSplitButton();
    splitButton.set_text("Split Button");
    var splitChildButton = new Telerik.Web.UI.RadToolBarButton();
    splitChildButton.set_text("button1");

    //inserts a new button at index 0 of the splitButton's Buttons collection
    splitButton.get_buttons().insert(0, splitChildButton);
    toolBar.commitChanges();

 
removeRadToolBarButtonnoneRemoves the specified button from the collection.

CopyJavaScript
    toolBar.trackChanges();

    //removes the first button from the dropDown's Buttons collection
    var firstChildButton = dropDown.get_buttons().getButton(0);
    dropDown.get_buttons().remove(firstChildButton);

    //removes the first button from the splitButton's Buttons collection
    var firstChildButton = splitButton.get_buttons().getButton(0);
    splitButton.get_buttons().remove(firstChildButton);
    toolBar.commitChanges();

 
clearnonenoneClears the Buttons collection of all the child buttons it contains.

CopyJavaScript
     

toolBar.trackChanges();
dropDown.get_buttons().clear();splitButton.get_buttons().clear();
toolBar.commitChanges()

 
getButtonintRadToolBarButtonReturns the button from the collection that resides at the specified index.

CopyJavaScript
var firstChildButton = dropDown.get_buttons().getButton(0);  
var firstChildButton = splitButton.get_buttons().getButton(0);

 
indexOfRadToolBarButtonintReturns the index of a button.

CopyJavaScript
var firstChildButton = dropDown.get_buttons().getButton(0);
dropDown.get_buttons().indexOf(firstChildButton);
var firstChildButton = splitButton.get_buttons().getButton(0);
splitButton.get_buttons().indexOf(firstChildButton);

 
removeAtintnoneRemoves the button at the specified index.

CopyJavaScript
     

//the code below will remove the first button in the collection
dropDown.get_buttons().removeAt(0);
splitButton.get_buttons().removeAt(0);

 
get_countnoneintReturns the number of the buttons in the collection.

CopyJavaScript
     

dropDown.get_buttons().get_count();
splitButton.get_buttons().get_count();