gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 934 forks source link

How do I set initial active filters? #1951

Open Lori-Becker opened 2 years ago

Lori-Becker commented 2 years ago

Maybe I'm not seeing it in the documentation, but I'd like to define a filter by default on my datatable. Similar to the sortOrder property in the table options object, I thought there might be something where I could set a default filter when the table is initialized, ie: column 'Author Name' where value = "Stephen King". Does MUI-datatables have this ability?

Expected Behavior

When defining table options, there is a property to set a specific set of active filters.

Current Behavior

Currently, filters can only be added by users interacting with the table's filter menu.

Your Environment

Tech Version
Material-UI 5.2.2
MUI-datatables 4.0.0
React 17.0.2
browser Chrome
codyng commented 1 year ago

Same question here!!

codyng commented 1 year ago

I found the answer. Just set the filterList from the column option, e.g. filterList: [ 'cat' ] I have searched for some questions with this same question but I couldn't find any answers. Why hasn't anyone addressed this question? :)