Clear All Filters

I’d like to have a button on a dashboard that clears all filters. Can I do that without a script? If not, does anyone have a script that allows me to do that?

Hi Brandon,

One easy trick if you want to have a full reset button is to add a button with a navigate interaction that brings you back to the same page. This will essentially reset everything on the dashboard and doesn’t require any script.

1 Like

This works perfectly, thanks Jeff.

@jeff
Does that work with Personalizations being saved?

Not sure - you’d have to test it but i believe personalization would get in the way. You’d probably have to force reset the personalization or turn it off.

https://www.dundas.com/support/learning/documentation/create-view-content/using-personalization

@brandon.maurer, I found this script somewhere. Maybe one of the trainings. Works well, too.

this.parentView.control.viewParameters.forEach(function(viewParameter, index) {
if (index != 0) { // skip the brush view parameter
    viewParameter.parameterValue.clearTokens();
    viewParameter.parameterValue.clearValues();
    viewParameter.parameterValue.token = new dundas.data.ParameterToken({
        // Use dundas.constants.ALL_TOKEN_DEFINITION_ID for "All" token
        "id": dundas.constants.DEFAULT_TOKEN_DEFINITION_ID,
        // Use "All" caption for All token
        "caption": "Default"
    });
    viewParameter.invalidateParameterValueLastModifiedTime();
    viewParameter.refreshAllAdapters();
}
});
4 Likes

This will definitely work and reset all view parameters to ‘Default’ token, which means ‘use the first value found in the chain when resolving parameters’ which is not necessarily the same thing as what the Dashboard loaded with.

So I would like to note that in v6.0.1 we did add a new ‘Reset Filter’ option to parameters in the token menu when a Dashboard is checked in and the values change.

This is accomplished in the JS API with 2 new methods (this code example would be executed from within an adapter action):

This would let you get the value that was there after everything loaded (including scripts which may have modified it). If you’re going to use one of these values, then you could do something like (basing it on the above script):

this.parentView.control.viewParameters.forEach(function(viewParameter, index) {
    if (!this.baseViewService.isViewParameterDefaultSnapshotValue(viewParameter)) {
        var snapshotValue = this.baseViewService.getViewParameterSnapshotDefaultValue(viewParameter);
        var clonedValue = Class.clone(snapshotValue);
        viewParameter.parameterValue = clonedValue;        
    }
}.bind(this));

// Efficient bulk update call.
dundas.view.ViewParameter.refreshAllViewParameters(this.parentView.control.viewParameters, this.parentView);
4 Likes

More of a subtopic related to this than an actual comment: Is there a way to automate this?

When using the dashboards made in Dundas, weve noticed that the values in the filter dont change back to default - even after a few days, or after logging out and in again (the dashboards are imported into a different software).

Is it possible to automatically reset all the filters to the default value after a configurable amount of time has passed? >> Yes just move the script of the reset button onto the loading event of the dashboard

HI,

I just had this came up with consumers of our dashboard. I have the RESET button on every layer/page that is using ‘Navigate Interaction’ as Jeff suggested above and it works great for me (I am ADMIN user in Dundas) - iow, it resets the dashboard to landing page and all parameters to DEFAULT parameteres (whatever was defined as default). Now, just as Pierre suggested right above - this does NOT work for our STANDARD users. They’ll click on RESET button but their parameter selections do NOT change - so I was not sure if this is related to them being STANDARD user v. me being ADMIN user. Any thoughts?

Thank you.

Hi Pierre and Semir,

What you’re describing sounds exactly like the “personalization” feature mentioned earlier, which is designed to save filter selections if you navigate away and come back, and also does not apply to administrator users. If you just don’t want personalization enabled, which is perfectly reasonable, you can disable the Store View Personalization privilege either on accounts or groups, or on individual views/dashboards:
https://www.dundas.com/support/learning/documentation/administration/list-of-application-privileges

This disables the storing of personalization, but this may not stop previously-saved personalization from loading like it’s already doing for you now, at least if you use the properties on a view. Users can clear personalization from their Profile dialog, or there is a method to clear personalization for everyone in the personalization article.

When you do want to save some filter selections, you can always still use the Share > Link option in the toolbar/context menu and bookmark or save it.

If personalization is enabled the script suggested by Christopher or Terrence should work to reset the filters for non-administrators, but you can also set up filter interactions on a component like a button without script that each set a view parameter to a specific value like All or Default.

4 Likes

Thanks Jamie, hugely appreciated - will read/try what you are suggesting.

The other option is to take the reset filters script from Christopher Simpson above and put it in the loading event of the dashboard. That way anytime a dashboard is refreshed the filters are reset as well

1 Like