Reset to default filters in new table

I would like a new API to be added to the table component: table.resetFilters() that resets the table filters back to the default filters set in the component configuration

With the new table, we can apply a default set of filters, and using the API for the table you can clear all filters or clear a specific filter, and add a filter or set the entire filter stack.

However, there is no API to reset the filters back to the default set of filters, hence this request.

Workaround: You can codify the ability to reset to default by setting the filters in a set filter stack call, but that can drift from the default filters over time if they are updated and the codified call is not. You could go further, and store the default filters into a variable and apply them that way, but this is not very user-friendly, compared to a simple resetFilters call (which I would have expected to exist already :sweat_smile:).

1 Like

Hi @Glen_Keane! There is a clearFilters API, but that will remove all filters and not reset to the default, so you're right that something native for resetting to defaults is missing.

One way you can accomplish it though is to set the filters to the value of table1._defaultFilters like is shown below. This will keep the filters in sync vs. hardcoding:

1 Like

Hi @mckenna .
There are some property start with _ of table component or other component, such as _columnEditable.
I have used it in my develop, but we can't access it in editor nor these properties show in the official docs.
Should I rely on this properties, it was a normal api? will it change without notification in the future?

1 Like

@AnsonHwang yes, hidden properties are not permanent APIs and are subject to change! You should treat accessing these properties like you would with custom CSS -- use with caution (though practically speaking I doubt something like _defaultFilters would ever change that fundamentally)

1 Like

How can we see the list of properties starting with _

:grinning:

Patrick

1 Like

Thanks for that info, I really appreciate it, and it solves this problem well. My feature request would be therefore could ‘_defaultFilters’ be made public in a future release? It makes sense to have this available.

Thanks again :pray:

console.log(JSON.tostringify(table1)) you will sell all the property of it, including hidden property

1 Like

@Glen_Keane following up here -- a resetFilterStack API will be available in next week's cloud release for reverting the table to its default filters!

3 Likes

A post was split to a new topic: [Feature Request] Add reset to default filter buttons to table

Hi @mckenna Why Can't I reset my filter stack from some other component. Have a look here ...

I am in Transaction View and I am reseting the filter stack of Receipts table (table3)

but It does not reset.


while It does when I do it in Receipts view

Hi @Bilal_Anjum Currently, you can't update the table filters when the table isn't visible on the page, but we've reported it to our team. I'll post here when we have a fix

1 Like