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

Possible bug: Setting SelectedTabIndex with invisible tabs

7 Answers 67 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Ioish
Top achievements
Rank 1
Ioish asked on 13 Mar 2012, 04:35 PM
Hi, I seem to have bumped into a bug with the RibbonBar control.

When setting SelectedTabIndex having 4 tabs, all of the visible, everything works normally:

Ribbon.SelectedTabIndex = Ribbon.Tabs.IndexOf(Ribbon 
.FindTabByValue("tabName"))

However when I make some tabs invisible (index 0 and 2 in my case), it completely messes up the SelectedTabIndex property:

It defaults to 1, and it seems to be impossible to change. Even having this value it is still inconsistent, showing either tab 1 or 3:

When tab 1 is selected client side and a postback occurs, the selected tab will switch to 3 on the client side after postback and vice versa. 

To make the tabs invisible I use: 
Menu.Tabs(0).Visible = False
Menu.Tabs(2).Visible  = False

Am I making a mistake or is this really a bug? 

Update:  It works when programatically removing the tabs before setting the index. This works for me as I won't need the invisible tabs on the client side or serverside anyway, but I imagine this might cause problems for other people.

7 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 16 Mar 2012, 09:49 AM
Hi Ioish,

Unfortunately I wasn't able to reproduce this issue. Perhaps I am missing something. Could you please specify the exact sequence of actions that leads to the problem. A video capture of it would also be very helpful.
 
All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ned
Top achievements
Rank 1
answered on 12 Apr 2012, 02:12 AM
I'd like to confirm this bug as stated by the original poster. When setting tab visibility, at least programmatically via C# code behind, the current RadRibbonBar selected tab index is lost (actually rewritten).

Example:

There are 7 visible tabs (indexes 0-6) and  fifth tab was selected as active (RadRibbonBar.SelectedTabIndex = 4). Make second tab invisible now (index 1) and RadRibbonBar.SelectedTabIndex now equals 5 which points to a different tab being selected than one desired.

It seems RadRibbonBar.SelectedTabIndex property is maintained only for visible members of collection although oddly the tab count does not increase/decrease.

I'm somewhat at odds with the original post as making the tabs invisible before setting the index screws things up anyway (using said C# code behind approach).
-----------------------------------------------------------------------
Code sample:

        private void DirectoryTabSetUp()
        {
            if (ClientsModules.HasFlag(ClientsModuleTypes.DirectoryAccess))
            {
                if (CurrentUserSettings.ContainsKey(UserSettingTypes.DirectoryAccessOnly))
                {
                    ribTabDrawings.Visible = true;//albeit this will be simplified version of Drawings
                    ribTabFiles.Visible = false;
                    ribTabAdmin.Visible = false;
                    rbTabReporting.Visible = false;
                    ribTabExplore.Visible = false;
                    RadRibbonBar.SelectedTabIndex = 4;
                    SimpleDrawingTabSetUp();
                }
            }
            else
            {
                ribTabDirectory.Visible = false;                
            }

        }

------------------------------------------------------------------------

For the above sample, all that matters is that ribTabDrawings has a tab index of 0 in collection and ribTabDirectory has tab index of 4. When one sets RadRibbonBar.SelectedTabIndex = 4 in the code above, SelectedTabIndex is coalesced to 0 making ribTabDrawings tab active. If I now wanted to make ribTabDirectory selected I'd need to code RadRibbonBar.SelectedTabIndex = 1 (effectively saying, hey there are now only 2 visible tabs, make the second one active). But that's just visual order (from left to right to boot).


Thanks,
Ned
0
Bozhidar
Telerik team
answered on 13 Apr 2012, 02:04 PM
Hi Ned,

Thank you for clarifying.

I confirm that this is a bug in the RibbonBar and I have logged it for fixing in our system.
 
All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bharath
Top achievements
Rank 1
answered on 18 Sep 2013, 03:48 PM
Has this been resolved?  We are using version 2013.1.220.40 and still have the same bug when setting few tabs to invisible.

Thanks,
Bharath
0
Bozhidar
Telerik team
answered on 20 Sep 2013, 07:16 AM
Hello Bharath,

Since this thread is more than a year old, could you provide the code for your current implementation and steps to reproduce, as well as the desired and actual results you are getting?
 

Regards,
Bozhidar
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Bharath
Top achievements
Rank 1
answered on 20 Sep 2013, 12:51 PM
Following is my code.  I am capturing the Tab Index on the click of RibbonBar buttons and redirecting to the page I wanted to and set the tab index on Page Load event.  All this happens on Master page.  We are using version 2013.1.220.40
Let me know if you need anything else.

        private int RibbonBarSelectedTab
        {
            set { Session["RibbonBarSelectedTab"] = value; }
            get { return (Session["RibbonBarSelectedTab"] != null) ? (int)Session["RibbonBarSelectedTab"] : 0; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Here the SelectedTabIndex is showing as 1 if I have the first Tab set to invisible.  If that is visible, then index shows as 0;
                this.MasterRadRibbonBar.SelectedTabIndex = this.RibbonBarSelectedTab;
            }
        }
    

        protected void MasterRadRibbonBar_ButtonClick(object sender, Telerik.Web.UI.RibbonBarButtonClickEventArgs e)
        {
            this.RibbonBarSelectedTab =e.Group.Tab.TabIndex;
            if(!string.IsNullOrEmpty(e.Button.CommandName.Trim())) { Response.Redirect(e.Button.CommandName.Trim()); }
        }

        protected void MasterRadRibbonBar_SplitButtonClick(object sender, RibbonBarSplitButtonClickEventArgs e)
        {
            this.RibbonBarSelectedTab = e.Group.Tab.TabIndex;
            if (!string.IsNullOrEmpty(e.Button.CommandName.Trim())) { Response.Redirect(e.Button.CommandName.Trim()); }
        }


        <telerik:RadRibbonBar ID="MasterRadRibbonBar" runat="server" Width="100%" OnButtonClick="MasterRadRibbonBar_ButtonClick" OnSplitButtonClick="MasterRadRibbonBar_SplitButtonClick"  >
            <Tabs>
                <telerik:RibbonBarTab Text="Accounting" Value="Accounting" TabIndex="0">
                    <telerik:RibbonBarGroup Text="Freight" EnableLauncher="false">
                        <Items>
                            <telerik:RibbonBarButton Size="Medium" Text="Reconciliation" ImageUrl="../Images/16X16/Reconciliation.PNG" CommandName="~/Application/Accounting/ReconciliationFreight.aspx" />
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>               
                <telerik:RibbonBarTab Text="CIP" Value="CIP" TabIndex="1">
                    <telerik:RibbonBarGroup Text="Improvements" EnableLauncher="false">
                        <Items>
                            <telerik:RibbonBarButton Size="Medium" Text="Action Request" ImageUrl="../Images/16X16/ActionRequest.png" CommandName="~/Application/CIP/ActionRequest.aspx" />
                            <telerik:RibbonBarButton Size="Medium" Text="CICAR" ImageUrl="../Images/16X16/CICAR.png" CommandName="~/Application/CIP/Cicar.aspx" />
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
            </Tabs>
        </telerik:RadRibbonBar>

0
Bozhidar
Telerik team
answered on 24 Sep 2013, 06:24 AM
Hi Bharath,

Thank you for the provided code.

The behavior you are observing is the expected one. Let me elaborate: when you set the first tab to be invisible, it cannot be selected. Therefore the ribbonbar selects the next visible tab (in your case the second one). That's why the index is showing as 1. If it were the other way around, and you only count the index of the visible tabs, then upon showing/hiding of tabs the selected index will suddenly point to a different tab, which might cause errors. 
 

Regards,
Bozhidar
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
RibbonBar
Asked by
Ioish
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Ned
Top achievements
Rank 1
Bharath
Top achievements
Rank 1
Share this question
or