With RadTabStrip it is easy to add, remove
or disable tabs at the client side. What is more, you can persist
the changes after postback.
<script type="text/javascript">
function addTab()
{
...
//Adds the tab to the Tabs Collection of the selected tab
selectedTab.get_tabs().add(tab);
tab.set_text("Child Tab " + selectedTab.get_tabs().get_count());
...
}
function removeTab()
{
...
//Removes the selected tab from the Tabs Collection of the tabstrip
tabStrip.get_tabs().remove(selectedTab);
}
function disableTab()
{
...
//Disables the selected tab
selectedTab.set_enabled(false);
}
</script>
If you want to persist these changes after postback, the methods described below
should be used:
- tabStrip.trackChanges(); -indicates that client-side changes
are going to be made and these changes are supposed to be persisted after postback.
- tabStrip.commitChanges(); - submits the changes to the server.
var tabStrip = $find("<%=RadTabStrip1.ClientID%>");
tabStrip.trackChanges();
//add, remove, disable tabs
tabStrip.commitChanges();
Client side changes are available on the server side after postback. You can use the
ClientChanges
property to access them:
foreach (ClientOperation<RadTab> operation in RadTabStrip1.ClientChanges)
{
RadTab tab = operation.Item;
switch (operation.Type)
{
case ClientOperationType.Insert:
break;
case ClientOperationType.Remove:
break;
case ClientOperationType.Update:
UpdateClientOperation<RadTab> update = operation as UpdateClientOperation<RadTab>;
break;
case ClientOperationType.Clear:
break;
}
}