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

Associating pageView id to Tabstrip Tab dynamically

1 Answer 74 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Rocky
Top achievements
Rank 1
Rocky asked on 02 Dec 2008, 08:00 PM

I am looking for dynamically adding Tabs in Tabstrip and adding pageView in Multipage and then associate the newly created pageView to Tab (similar to tabs in IE).  But I couldn’t find a way to do this from the documentation. Can you please help?


here is the sample code I am trying. 

 

<body>

<script language="javascript" type="text/javascript">

 

    function AddNewTabs() {

       

 

        var multiPage = $find("<%=RadMultiPage1.ClientID %>");

        multiPage.trackChanges();

        var pageView = new Telerik.Web.UI.RadPageView();

        pageView.set_id("id1");

        multiPage.get_pageViews().add(pageView);

        pageView.get_element().innerHTML = "PageView1";

        //pageView.get_element().id = "id1";

        multiPage.commitChanges();

 

        var tabstrip = $find("<%= RadTabStrip1.ClientID %>");

        var roottab = new Telerik.Web.UI.RadTab();

        roottab.set_text("ReportPageView");

        roottab.set_pageViewID("id1");

        tabstrip.trackChanges();

        tabstrip.get_tabs().add(roottab);

        tabstrip.commitChanges();

    }

   

 

   

    </script>

    <form id="form1" runat="server" defaultfocus="Button1">

   

    <asp:ScriptManager ID="ScriptManager" runat="server" />

   

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="AddNewTabs();"/>

   

    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">

       <Tabs>

           <telerik:RadTab runat="server" Text="Root RadTab1" PageViewID="CommencePageView"/>

       </Tabs>

    </telerik:RadTabStrip>

      

    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">

        <telerik:RadPageView ID="CommencePageView" runat="server">

            <div>Comments</div>

        </telerik:RadPageView>

    </telerik:RadMultiPage>

   

    </form>

</body>

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 04 Dec 2008, 03:40 PM
Hello Rocky,

This code does not work because the button posts back after clicking. The id property of the pageview is not persisted to the server side at the time being which effectively prevents the tab from knowing its associated pageview. If you need the pageview only on the client side you may consider preventing the button from posting back:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return AddNewTabs();" />
 function AddNewTabs() {
   ....
  return false;

}

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ToolTip
Asked by
Rocky
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or