Legend Filter - Scripting not properly executed in the embedded view

Hi everyone,

I have included a script in a dashboard for passing the value from a legend to a parameterHierarchy (filter). If the user clicks on the legend, the view gets filtered. The script is working fine in the dashboard itself. However, I use this dashboard embedded in another, and from there the script doesn’t refresh the parameter. The value from the legend is passed to the filter, but the view doesn’t get updated. I wonder if someone could help me with that.
Here is the script.

// Get the hit test arguments.
var hitTestArgs = legend1.getHitTestArguments(e);

// Get the viewParameter
var viewParameter = this.parentView.control.getViewParameterByName(“viewParameter1”)

// Get the hit test result, which is an array of:
var hitTestResult = legend1.control.hitTest(hitTestArgs.offsetX, hitTestArgs.offsetY, hitTestArgs.target);

if(hitTestResult.length > 0)
{
var clickedLegendItem = hitTestResult[0];

// Get the hit text result and pass it to a filter.
var filterValue = new dundas.data.MemberValue({
hierarchyUniqueName: “Name”,
levelUniqueName: “Name”,
uniqueName: clickedLegendItem.text + “.Name”
});

viewParameter.parameterValue.token = null;
viewParameter.parameterValue.values.length = 0;
viewParameter.parameterValue.values.push(filterValue);

viewParameter.invalidateParameterValueLastModifiedTime();
viewParameter.refreshAllAdapters();

}
else
{
// No item was clicked reset the filter.
viewParameter.parameterValue.clearTokens();
viewParameter.parameterValue.clearValues();
viewParameter.parameterValue.token = new dundas.data.ParameterToken({
“id”: dundas.constants.ALL_TOKEN_DEFINITION_ID,
“caption”: “All”
});
viewParameter.invalidateParameterValueLastModifiedTime();
viewParameter.refreshAllAdapters();
}

I have figured out the solution.
I included a loop to loop through the adapters and refresh the data.
Thanks anyway!

Glad you got it solved, Diego. I think it might have had something to do with your loop. :smiley:

1 Like