New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

RadTabCollection Object

The RadTabCollection object is returned by the get_tabs() method of the RadTabStrip or the RadTab object. The following table lists the most important methods of the object.

NameParametersReturn TypeDescription
addRadTabnoneAdds a tab to the collection. See Example 1.
insertint, RadTabnoneInserts the tab into the collection at the position defined by the first (index) parameter. See Example 2.
removeRadTabnoneRemoves the specified tab from the collection. See Example 3.
clearnonenoneClears the Tabs collection of all the child tabs it contains. See Example 4.
getTabintRadTabReturns the tab from the collection that resides at the specified index. See Example 5.
indexOfRadTabintReturns the index of a tab. See Example 6.
removeAtintnoneRemoves the tab at the specified index. See Example 7.
get_countnoneintReturns the number of the tabs in the collection. See Example 8.

Changes to the tab 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 tab strip object.

Note that clearing the collection using the clear() method will not persist after postback even if implemented between trackChanges() and commitChanges() calls.

Example 1. Add tab to the RadTabCollection

JavaScript
function addNewTab() {  
	var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
	var tab = new Telerik.Web.UI.RadTab();
	tab.set_text("New Tab");
	tabStrip.trackChanges();
	tabStrip.get_tabs().add(tab);
	tabStrip.commitChanges();       
} 	

Example 2. Insert tab at specific index

JavaScript
function insertNewTab() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	tabStrip.trackChanges();
	var tab = new Telerik.Web.UI.RadTab();
	tab.set_text("tab1");
	tabStrip.get_tabs().insert(0,tab);
	tabStrip.commitChanges();
} 			

Example 3. Remove tab from the RadTabCollection 

JavaScript
function removeTab() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	tabStrip.trackChanges();
	var tab = tabStrip.get_tabs().getTab(0);
	tabStrip.get_tabs().remove(tab);
	tabStrip.commitChanges();
}

Example 4. Clear the RadTabCollection

JavaScript
function clearTabCollection() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	tabStrip.trackChanges();
	tabStrip.get_tabs().clear();
	tabStrip.commitChanges(); 			
}

Example 5. Get tab at specific index

JavaScript
function getTabAtPosition() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	var tab = tabStrip.get_tabs().getTab(0);
	alert(tab.get_text());
}

Example 6. Get the index of a tab

JavaScript
function getTabPosition() {	
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	var rootTab1 = tabStrip.get_tabs().getTab(0);
	var index = tabStrip.get_tabs().indexOf(rootTab1);

	//to get the index of the first child of the first root tab
	var firstChild = tabStrip.get_tabs().getTab(0).get_tabs().getTab(0);
	var firstChildIndex = tabStrip.get_tabs().getTab(0).get_tabs().indexOf(firstChild); 	
}

Example 7. Remove tab at specific index

JavaScript
function removeTabAtPosition() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	var tab = tabStrip.findTabByText("Child RadTab 1");
	var tabs = tab.get_parent().get_tabs();
	var index = tabs.indexOf(tab);
	tabs.removeAt(index); 			
}

Example 8. Get count of tabs

JavaScript
function alertTabsText() {
	var tabStrip = $find("<%=RadTabStrip1.ClientID %>");
	var tabs = tabStrip.get_tabs();
	for (var i=0; i < tabs.get_count(); i++) {
		alert(tabs.getTab(i).get_text());
	}
} 	 

See Also

In this article
See Also
Not finding the help you need?
Contact Support