Hide/disable Tab on OnTabDataBound

3 posts, 1 answers
  1. Softec
    Softec avatar
    45 posts
    Member since:
    Sep 2007

    Posted 08 Sep 2009 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Sep 2009 Link to this post

    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
  3. Softec
    Softec avatar
    45 posts
    Member since:
    Sep 2007

    Posted 09 Sep 2009 Link to this post

    Thanks for your reply, it sent me looking further around and I found the problem at another place! 
Back to Top