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

Get Next/Previous Tab

3 Answers 68 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Neil N
Top achievements
Rank 1
Veteran
Iron
Neil N asked on 01 Oct 2010, 01:12 PM
I've got a tabstrip with tabs and subtabs.  Some of these tabs/subtabs are disabled or invisible.  What I'm trying to do is get the next and previous active tab/subtab with reference to the currently selected tab/subtab (if the rightmost tab in a "subtabstrip" is selected then I need to get the next "main" tab).  I think this is fairly simple but I'm missing something.  Is there some sample code I can look at?

3 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 07 Oct 2010, 02:18 PM
Hello Neil,

Please find a sample code how to achieve this:

<asp:ScriptManager ID="ScriptManager1" runat="server">
 </asp:ScriptManager>
<telerik:RadTabStrip ID="RadTabstrip1" runat="server" OnClientTabSelecting="tabSelecting">
    <Tabs>
    <telerik:RadTab runat="server" Text="Tab1">
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab2" Selected="true">
        <Tabs>
        <telerik:RadTab runat="server" Text="Child RadTab 1">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 2">
        </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab3" Visible="false">
        <Tabs>
        <telerik:RadTab runat="server" Text="Child RadTab 1">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 2">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 3">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 4">
        </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab4">
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab5">
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab6">
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab7">
    </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<script type="text/javascript">
 
    function tabSelecting(sender, eventArgs) {
 
    var tabstrip = $find("<%=RadTabstrip1.ClientID %>");
    if (eventArgs.get_tab().get_level() != 0)
    {
        var parentTab = eventArgs.get_tab().get_parent();
        parentTab.get_nextSibling().select();
    }
     
    }
 
</script>

More about RadTab client-side you may find here.

Regards,
Helen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Neil N
Top achievements
Rank 1
Veteran
Iron
answered on 07 Oct 2010, 02:33 PM
Hi Helen, sorry, I should have specified I need to do this on the server side (in a button clicked event).  There seems to be no equivalent to get_nextSibling in the server API.
0
Helen
Telerik team
answered on 08 Oct 2010, 04:17 PM
Hello Neil,

It will not so easy to do it server-side. Please find below a sample code to start from:

aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadTabStrip ID="RadTabstrip1" runat="server"
        ontabclick="RadTabstrip1_TabClick" SelectedIndex="1">
    <Tabs>
    <telerik:RadTab runat="server" Text="Tab1">
        <Tabs>
            <telerik:RadTab runat="server" Text="Child RadTab 1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Child RadTab 2">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab2" Selected="true">
        <Tabs>
        <telerik:RadTab runat="server" Text="Child RadTab 1">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 2">
        </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab3" Visible="false">
        <Tabs>
        <telerik:RadTab runat="server" Text="Child RadTab 1">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 2">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 3">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Child RadTab 4">
        </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab4">
        <Tabs>
            <telerik:RadTab runat="server" Text="Child RadTab 1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Child RadTab 2">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Child RadTab 3">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab5" Enabled="False">
        <Tabs>
            <telerik:RadTab runat="server" Text="Child RadTab 1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Child RadTab 2">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Child RadTab 3">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab6">
    </telerik:RadTab>
    <telerik:RadTab runat="server" Text="Tab7">
    </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>

cs:
protected void RadTabstrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
{
    if (e.Tab.Parent.GetType() != typeof(RadTabStrip))
    {
        RadTab parentTab = (RadTab)e.Tab.Parent;
        int index = parentTab.Index;
        do
        {
          index = index + 1;
        }
while (RadTabstrip1.Tabs[index].Visible == false || RadTabstrip1.Tabs[index].Enabled == false);
        RadTabstrip1.Tabs[index].Selected = true;
    }
}

Hope this helps.

Sincerely yours,
Helen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TabStrip
Asked by
Neil N
Top achievements
Rank 1
Veteran
Iron
Answers by
Helen
Telerik team
Neil N
Top achievements
Rank 1
Veteran
Iron
Share this question
or