Forum Discussion
JackLacava
I stumbled on your posts and attempted to implement the Repeater to dynamically show/hide tabs but was unsuccessful.
Could you please share and example?
Thank you in advance!
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 Function
To 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.
Related Content
- 3 years ago
- 1 year ago