Forum Discussion

Shubham0512's avatar
Shubham0512
New Contributor
1 day ago

Hide Tabs in Dashboard

Hi,

I have a dashboard with 5 tabs which is assigned to a workflow step.

One of the tab has a cube view where assumptions are inputted. I want this tab to be visible only for administrators and not for every user.

IsVisible is something i have used to hide dashboard components with an XFBR but i dont see the same option for embedded dashboard.

Is there a way to get this done?

2 Replies

  • db_pdx's avatar
    db_pdx
    Valued Contributor

    Hi Shubham0512: this can be accomplished but requires the use of DynamicDashboard components. Instead of adding the subdashboards directly to your tabbed dashboard in the GUI. You'll add them via code in the DynamicDashboard assembly. In the code you'll perform the check for Admin/SecurityGroup and only add your last dashboard if the user meets the requirement.

    You'll need:

    • A dashboard that is type = Embedded Dynamic Repeater. Its only component is a manually created Embedded Dashboard
    • The manually created Embedded Dashboard will have your template parameters that control the display name (tab name) and a reference to the actual sub dashboard components to use
    • A DynamicDashboard assembly that controls which tabs to display

    Sample code for adding the tabs.

    #Region "Dynamic Tabs based on Access Group"
     If storedDashboard.Name.XFEqualsIgnoreCase("1_HT_TabsDynamic") Then
    	'#### Create Repeat Args = Collection ####
    	Dim repeatArgs As New List(Of WsDynamicComponentRepeatArgs)
    	'#### Tabs for Everyone ####
    	repeatArgs.Add(New WsDynamicComponentRepeatArgs("Tab1", New Dictionary(Of String, String) From {
    			{"DisplayName", "Hello World"},
    			{"DashboardName", "HT_Tab1"}
    			}))
    	repeatArgs.Add(New WsDynamicComponentRepeatArgs("Tab2", New Dictionary(Of String, String) From {
    			{"DisplayName", "Second"},
    			{"DashboardName", "HT_Tab2"}
    			}))
    	'#### Tabs Only for Security Group ####	
    	If BRApi.Security.Authorization.IsUserInGroup(si, si.UserName, "FakeAccessGroupForDemo", True) Then
    	repeatArgs.Add(New WsDynamicComponentRepeatArgs("Tab3", New Dictionary(Of String, String) From {
    			{"DisplayName", "ADMIN ONLY"},
    			{"DashboardName", "HT_AdminOnly"}
    			}))
    	End If
    	'#### Create the dashboard ####
    	Dim thisDashboard As WsDynamicDashboardEx = api.GetEmbeddedDynamicDashboard(si, _ 
    		workspace, parentDynamicComponentEx, _
    		storedDashboard, String.Empty, Nothing, _
    		TriStateBool.Unknown, WsDynamicItemStateType.Unknown)
    	'Add our Collection of repeated things to it
    	thisDashboard.DynamicDashboard.Tag = repeatArgs
    	'Return this object
    	Return thisDashboard
    End If
    #End Region
    

    Screenshots

    Example components:

    The Embedded Dashboard component:

    Output of the view all users see:

    Output of the view authorized users see:

     

    All the assembly stuff is on the advanced side, so if you are new to it try following some of the guides/samples in the documentation before working on your actual components.  Good luck!

  • sameburn's avatar
    sameburn
    Icon for OneStream Employee rankOneStream Employee

    Hi Shubham0512​ 

    This is possible but not really with Tabs.

    Tabs aren't recommend really as each time you refresh the dashboard holding the tabs you (a) refresh all tabs and (b) by default end up back to first tab. So you have less control 

    I would therefore recommend using a component like a button to simulate the tab and trigger a refresh of the dashboard content you want to show.  In this simple example (that isn't formatted) we demonstrate how we click the first button and it shows Tab1 Content

    if we click button 2, we get Tab2, Button 3 shows Tab3, etc

    This is a simple trick using an embedded dashboard component that is not associated with a real dashboard.

    Where the parameter is used to determine the dashboard to show...

     

    ... and the buttons pass a value to that parameter and trigger a refresh of the dashboard we want to refresh e.g c_Content.

    This is a simple no-code trick.  Obviously if you want less components then you can use Dynamic Dashboards, for example. Please be aware, this requires code... but opens up a lot more options about how you can approach this.  

    If I want to remove content based on a condition we can do this by controlling the IsVisible property of the button, which then controls the dashboard content. You can use an XFBR rule here if your logic for isVisible is more complex e.g. checking a user is in a security group, for example

    If I then make the button for Tab 3 not visible

    Then that button and content is no longer visible.  

     

    Hope this helps clarify options for how to approach this

    Sam