This is a migrated thread and some comments may be shown as answers.

add tab clientside

1 Answer 51 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Sigma
Top achievements
Rank 1
Sigma asked on 01 Jul 2012, 05:29 PM
Hi.

How can i add new tab to a radTabstrip and then associate it with a PageView in the client side?

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Jul 2012, 06:39 AM
Hi Sigma,

Try the following code snippet to achieve your scenario.

ASPX:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">
  <Tabs>
     <telerik:RadTab runat="server" Text="Root Tab 1" PageViewID="PageView1" />
     <telerik:RadTab runat="server" Text="Root Tab 2" PageViewID="PageView2" />
     <telerik:RadTab runat="server" Text="Root Tab 3" PageViewID="PageView3" />
  </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server">
   <telerik:RadPageView ID="PageView1" runat="server">PageView 1</telerik:RadPageView>
   <telerik:RadPageView ID="PageView2" runat="server">PageView 2</telerik:RadPageView>
   <telerik:RadPageView ID="PageView3" runat="server">PageView 3</telerik:RadPageView>
   <telerik:RadPageView ID="PageView4" runat="server">PageView 4</telerik:RadPageView>
</telerik:RadMultiPage>
<input type="button" runat="server" onclick="AddSampleTab()" value="Add New Tab" />

JS:
<script type="text/javascript">
    function AddSampleTab() {
        var tabstrip = $find('<%=RadTabStrip1.ClientID%>');
        var tab = new Telerik.Web.UI.RadTab();
        tab.set_text("Root Tab 4");
        tabstrip.trackChanges();
        tabstrip.get_tabs().add(tab);
        tabstrip.commitChanges();
        var multiPage = $find('<%=RadMultiPage1.ClientID%>');
        var fourthPageView = multiPage.get_pageViews().getPageView(3)
        tab.PageViewId = "PageView4";
        tab.PageViewClientID = fourthPageView.ClientID;
        tabstrip.set_selectedIndex(3);
    
</script>

Hope this helps.

Thanks,
Princy.
Tags
TabStrip
Asked by
Sigma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or