material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Clear Filters Button

Open Edisonsan opened this issue 7 years ago • 4 comments

There is some method actually to enable a clear filters button? Must be near or download the ACTIONS header column, something licke CLEAR

Edisonsan avatar Sep 26 '19 21:09 Edisonsan

No. There should be. But there's none. Potentially you could add one by overriding TableFilterRow component.

PS All caps is interpreted as shouting. So why do you shout at us?

jayarjo avatar Sep 27 '19 05:09 jayarjo

No. There should be. But there's none. Potentially you could add one by overriding TableFilterRow component.

PS All caps is interpreted as shouting. So why do you shout at us?

My apologies; i did modify the title.

How i can use MTableFilterRow to clear the bottom, i try to forceUpload all the component table, reset the state, etc, but nothing works.

Edisonsan avatar Sep 28 '19 20:09 Edisonsan

There's no clear filters button, but you can still clear filters using methods by accessing the tableRef object and manually them out. For example:

let self = this.tableRef.current; // get the tableRef
let query = self.state.query; // get the query obj
self.setState({
    ...self.dataManager.getRenderState(), // set the render state
    query: {
        ...query,
        filters: [] // set filters to nothing
    }
});
// you also need to update the filter value on the column by doing this:
for ( var item in this.tableRef.current.state.query.filters ) {
    let tableColumn = this.tableRef.current.state.query.filters[item].column
    this.tableRef.current.dataManager.changeFilterValue(tableColumn.tableData.id, null)
}

I don't think this is really "recommended", though, but this is how I was able to solve this problem for myself.

ATLUSio avatar Nov 04 '19 23:11 ATLUSio

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jun 15 '20 11:06 stale[bot]