Clear all filters

  • 3
  • Question
  • Updated 2 years ago
Is there a way to implement a "clear all filters" button?

We have tables that have 15+ filters. It would be convenient to be able to clear all of them at one time.

Currently if a filter was created on a table, there's no option to deactivate the condition on the actions menu.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb

Posted 2 years ago

  • 3
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
As far as I know there is no simple way to accomplish this as of now , and it has been requested many times.

If your filters are based on conditions (not auto-filters) you can accomplish roughly the same

Create a new filter with select option, and options: manually, then create 1 "options"  and add as many "other condition" as needed , and each  De-activating the condition filter(s)  based on

If you need a more detailed explanation feel free to ask, I will post some screenshots

Hope it helps
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
Thanks for the reply. These are mostly multi-select picklists and have been created automatically.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You can create a snippet to do this. Loop through conditions that have a name are activated and deactivate.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
These conditions don't have names, because they were created with a table filter. Can I still use javascript to clear them?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Though you didn't provide the names, they should still have names created automatically by the table filter.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
They do. I tried changing the XML to include a deactivate condition using the auto created name. But it didn't work. 

Do you have an example of javascript? I could try that.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hmmmm ... not sure what you were doing in the xml. No need to go in there.

Video tutorial how-to time.

(Edited)
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
Here's what I used, it works! Thanks for the help.

var params = arguments[0],
    model = params.model,
	$ = skuid.$;
	
$.each(model.conditions, function(c, condition){
    if(condition.name && !condition.originalValue){
        model.deactivateCondition(condition);
    }  else if (condition.name && condition.originalValue) {
        model.activateCondition(condition);
        model.setCondition(condition,condition.orignalValue);
    }
});
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
After further testing, the above javascript was not updating originally inactive filters to inactive, so I adjusted the javascript, and appears to be working correctly:

var params = arguments[0],
    model = params.model,
	$ = skuid.$;
	
$.each(model.conditions, function(c, condition){
    if(condition.name && condition.originalInactive === true){
        model.deactivateCondition(condition);
    }  else if (condition.name && condition.originalInactive === false) {
        model.activateCondition(condition);
    }
});