Selecting a tab at the 2nd level doesn't change the view

4 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 11 Jun 2012 Link to this post

    I have a tab strip defined like this ...
    <telerik:RadTabStrip runat="server"
                         ID="RadTabStrip1"
                         MultiPageID="RadMultiPage1"
                         ScrollChildren="true"
                         ScrollButtonsPosition="Right"
                         PerTabScrolling="true"
                         SelectedIndex="0">
        <Tabs>
            <telerik:RadTab Value="tsSearch"
                            Text="Search"
                             ScrollChildren="true"
                             ScrollButtonsPosition="Right"
                             PerTabScrolling="true">
                <Tabs>
                    <telerik:RadTab Value="tsSearchBasic"
                                    Text="Quick"
                                    PageViewID="pvSearchBasic"/>
                    <telerik:RadTab Value="tsSearchAdvanced"
                                    Text="Advanced"
                                    PageViewID="pvSearchAdvanced"/>
                </Tabs>
            </telerik:RadTab>
            <telerik:RadTab Value="tsDetails"
                            Text="Details"
                             ScrollChildren="true"
                             ScrollButtonsPosition="Right"
                             PerTabScrolling="true">
                <Tabs>
                    <telerik:RadTab Value="tsBusiness"
                                    Text="Business"
                                    PageViewID="pvBusiness"/>
                    <telerik:RadTab Value="tsPersonal"
                                    Text="Personal (Phone/Email)"
                                    PageViewID="pvPersonal"/>
                    <telerik:RadTab Value="tsPostal"
                                    Text="Personal (Address)"
                                    PageViewID="pvPostal"/>
                </Tabs>                
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>

    Now, if I have a 2nd-level tab on tsDetails selected and run this fowllowing javascript ...

    startTab = tabStrip.findTabByValue("tsSearchBasic");
    if (startTab != null)
    {
        startTab.select();
        startTab.scrollIntoView();
    }

    What happens is that the relevant PageView shows, suggesting that the correct tab has been selected. However, the tabstrip itself doesn't change.

    Rightly or wrongly, I was expecting the top-level tab "Search" to be come active and the relevant 2nd-level tab to be selected.

    Either I'm doing it wrong, my expectations are incorrect or it's broken.

    Anyone care to hazard a guess?

    [later]
    I suspect my expectations are wrong  :-( as it works as I've described on this demo page too.



  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 11 Jun 2012 Link to this post

    On the assumption that I had set an unreasonable level of expectation, I modified my code to read ...
    startTab = this.tabStrip.findTabByValue("tsSearchBasic");
    // ...
    if (startTab != null)
    {
        if (startTab.get_level() > 0)
        {
            startTab.get_parent().select();
            startTab.get_parent().scrollIntoView();
        }
        startTab.select();
        startTab.scrollIntoView();
        if (startTab.get_level() == 0)
        {
            if (startTab.get_tabs().get_count() > 0)
            {
                startTab.get_tabs().getTab(0).select();
            }
        }
    }

    If anyone finds themself with a simlar problem.

    I still think that expecting the hierarchical view of the tabs to change when you programmatically select a lower-level tab is a valid one though.
    --
    Stuart

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 11 Jun 2012 Link to this post

    Hello Stuart,

    Apparently there is also a selectParents() method that you use to select all parent tabs for a selected RadTab object. So you could just call, startTab.selectParents(), instead of checking the level to determine if the parent should be selected.

    This method exists in the latest version of the controls, at least the ones used on the demo pages, so I'm not sure if it would be available with the version you're using.
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 11 Jun 2012 Link to this post

    Thanks Kevin,

    That call's not in the docs (at least not the .chm version).

    Modified my code to suit.

    Thanks again.

    --
    Stuart
Back to Top