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

Hide/disable Tab on OnTabDataBound

2 Answers 115 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Softec
Top achievements
Rank 1
Softec asked on 08 Sep 2009, 11:20 AM
Hi

I've bound my RadTabStrip to a SiteMapDataSource and want to hide or disable certain tabs depending on SiteMapNodeAttributes. But my settings (enabled/visible) are ignored. 

(GetBool() is a function to test and cast the value, true is the fallback value.)
 
        protected override void OnTabDataBound(telerik.RadTabStripEventArgs e) 
        { 
            e.Tab.Enabled = (e.Tab.DataItem as System.Web.SiteMapNode)["enabled"].GetBool(true); 
            e.Tab.Visible = (e.Tab.DataItem as System.Web.SiteMapNode)["visible"].GetBool(true); 
 
            base.OnTabDataBound(e); 
        } 

The only way to hide a tab was by removing it completly...
 
            if (!(e.Tab.DataItem as System.Web.SiteMapNode)["visible"].GetBool(true)) 
            { 
                this.Tabs.Remove(e.Tab); 
            } 

So when is the right moment to do this? I tried it in OnDataBound but then the DataItem of the node is empty...

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Sep 2009, 10:33 AM
Hi Studatch,

I tried following code snippet in order to hide the tabs based on SiteMapNode attributes. Give a try with this.

C#:
 
protected void RadTabStrip1_TabDataBound1(object sender, RadTabStripEventArgs e) 
    e.Tab.Enabled = Convert.ToBoolean((e.Tab.DataItem as System.Web.SiteMapNode)["enabled"]); 
    e.Tab.Visible = Convert.ToBoolean((e.Tab.DataItem as System.Web.SiteMapNode)["visible"]); 
Also you can checkout the following documentation that shows how to use SiteMapDataSorce with RadTabStrip:
SiteMapDataSource

-Shinu
0
Softec
Top achievements
Rank 1
answered on 09 Sep 2009, 11:37 AM
Thanks for your reply, it sent me looking further around and I found the problem at another place! 
Tags
TabStrip
Asked by
Softec
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Softec
Top achievements
Rank 1
Share this question
or