The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
FabioG
7 months agoContributor II
Programmatically hide dashboard Tabs
Hi all, I want to manage tabs on a dashboard in a programmatically way, showing/hiding them based on the result of an XFBR call (or similar). Can someone point me in the right direction, please ? ...
- 5 months ago
This is the simplest approach (there are others).
Have a "Layout" dashboard of type Embedded Dynamic Repeater, with Layout Type set to Tabs.
Have your other dashboards of type Embedded
Create a Component "TabTemplate" of type Embedded Dashboard, and set a variable in the Embedded Dashboard property.
Assign that component to the Layout dashboard
Now create your "MyTabAssembly" assembly, containing a Dynamic Dashboard Service "MyDynDashService".
This is the core of the technique: in the GetEmbeddedDynamicDashboard method, manipulate the ComponentTemplateRepeatItems list to define items; for each item, the variable we used in our Embedded Dashboard component will be populated to point to a particular dashboard.
Public Function GetEmbeddedDynamicDashboard(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _ ByVal maintUnit As DashboardMaintUnit, ByVal parentDynamicComponentEx As WsDynamicComponentEx, ByVal storedDashboard As Dashboard, _ ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) As WsDynamicDashboardEx Implements IWsasDynamicDashboardsV800.GetEmbeddedDynamicDashboard Try If (api IsNot Nothing) Then If storedDashboard.Name.XFEqualsIgnoreCase("Layout") Then ' get the dashboard Dim layoutDashboard = api.GetEmbeddedDynamicDashboard(si, workspace, parentDynamicComponentEx, storedDashboard, String.Empty, Nothing, TriStateBool.Unknown, WsDynamicItemStateType.Unknown) ' build an item definition with suffix and variable values Dim newTab = New XFDynamicDashboardTemplateItemDefinition("t1", "d=Tab_1") ' manipulate the list layoutDashboard.DynamicDashboard.ComponentTemplateRepeatItems.Add(newTab) ' return the dashboard return layoutDashboard Else Return api.GetEmbeddedDynamicDashboard(si, workspace, parentDynamicComponentEx, storedDashboard, String.Empty, Nothing, TriStateBool.Unknown, WsDynamicItemStateType.Unknown) End If End If Return Nothing Catch ex As Exception Throw New XFException(si, ex) End Try End FunctionTo clarify, and if you want to test manually before using code, this snippet is manipulating this property on the Layout dashboard:
Effectively doing the same as:
Now create your Service Factory and enable your service as usual
Execute it in Designer mode, and you'll see that the dashboard includes your tab.
If you want more tabs, just add (or remove) items from that ComponentTemplateRepeatItems list. If you want to drive it with Parameters (e.g. the number of tabs, or anything else), you will find them in the customSubstVarsAlreadyResolved dictionary.
DanielWillis
7 months agoValued Contributor
Just confirming what Sergey said, This was an example of the power of dynamic dashboards, where you could truly hide/show content rather than a 'soft' hide which often left you with formatting issues / blank space.
FabioG
7 months agoContributor II
Hi all,
what I want to show/hide is not the content... While using the Tab Layout, I'd like to show/hide tab buttons programmatically, like adding/removing underlying dashboards. These are not buttons (or components) on a dashboard, they are part of the control.
AFAIK this cannot be done programmatically.
Suppose I have Tab1, Tab2 and Tab3. In certain conditions I want to hide Tab2 button, so the tab control has only 2 tabs available. I was able to do so implementing removing the Tab layout and adding a set of buttons that I can show/hide programmatically.
Regards
FabioG
- JackLacava7 months ago
OneStream Employee
It can be done programmatically just fine, but it's an advanced technique that requires a Dynamic Dashboard Service implementing a Repeater pattern.
The dashboard with a Tab layout would be set as an Embedded Dynamic Repeater which is then populated with a variable number of Embedded Component instances, each pointing to the dashboard to include in each tab. You would have to force a reload of the tabbed interface each time you want to modify the number of tabs, which might be a bit awkward depending on the version you're using (it might not retain the currently-selected tab).
Tabbed layouts are generally discouraged anyway - they look a bit dated and they tend to load all the linked dashboards even if not displayed, which might result in slow loading times. But if you are interested I can put together an example.
- DanielWillis7 months agoValued Contributor
So your dynamic dashboard would be a tab layout and you would programmatically add the dashboards that you want to show up as visible tabs. Adding dashboards is what makes the tabs show up right?
Honestly haven't done it but I don't see why it can't happen.
Related Content
- 5 months ago
- 2 years ago