Hello James,
The “Collapse All” is a metric set setting found in the data analysis panel. You can override many different metric set settings using JavaScript while viewing a dashboard using the request overrides. For this particular case, you can use the retrieveAllMemberOnly on the hierarchy overrides.
- Here is a link to our API that goes into more detail about the request overrides:
- Here is another link to our API that references the request hierarchy overrides :
If you need to reference how this is implemented on a dashboard, you can go to our Script Library on our support site. Below is a sample of how to set metric set overrides via scripting. At line 101 of the sample, it shows how to implement the retrieveAllMemberOnly on a specific hierarchy.
You can collapse as many hierarchies you want, as long as you define a new override for the hierarchy inside the metric set, and push that override.
In the example below, I have two hierarchies with the unique names DueDate and TerritoryID; I created two hierarchy overrides to be pushed on the click action of a button. The result of this script is when I click the button, both hierarchies defined inside my overrides are collapsed.
Script:
var view = this.parentView;
var requestOverrides = new dundas.data.RequestOverrides();
var hierarchyOverride1 =
new dundas.data.RequestHierarchyOverrides(
{
retrieveAllMemberOnly: true,
uniqueName: 'DueDate'
}
);
var hierarchyOverride2 =
new dundas.data.RequestHierarchyOverrides(
{
retrieveAllMemberOnly: true,
uniqueName: 'TerritoryID'
}
);
requestOverrides.hierarchyOverrides.push(hierarchyOverride1);
requestOverrides.hierarchyOverrides.push(hierarchyOverride2);
// Get the metric set binging override.
var metricSetBindingOverride =
view.control.overrides.getMetricSetBindingOverrideById(table1.id, table1.metricSetBindings[0].id);
if (metricSetBindingOverride)
{
// Update the existing override.
metricSetBindingOverride.requestOverrides = requestOverrides;
}
else
{
// Add new override as one doesn't exist.
view.control.overrides.metricSetBindingOverrides.push(
{
adapterId: table1.id,
metricSetBindingId: table1.metricSetBindings[0].id,
requestOverrides: requestOverrides
}
);
}
// Call load data on the adapter.
var dataLoadPromise = table1.loadData();