OnFilter change options of other filters
See original GitHub issueHi I am using the react-bootstrap-table to display some information in a nice table structure. However I am running into the issue that the filter options for the select filter won’t update. So I was wondering if there is an easy way of having the options default to the values that are currently available in the table for that column.
I am currently getting the categories by creating a set of each relevant category using this.state.data, which however won’t update when filtering by any category and thus the options in each select filter always stay the same.
<BootstrapTable keyField='id' data={this.state.data} columns={columns} filter={filterFactory()} resize={{extra: 80}} headerClasses='bootstrap-table-header' striped hover condense />
where columns is something like this:
const columns = [
{ dataField: 'category_1',
text: 'Category_1',
headerFormatter: this.headerFormatter,
sort: true,
filter: selectFilter({
placeholder: 'Category 1...',
options: this.getCategory1()
})
},
{ dataField: 'category_2',
text: 'category_2',
headerFormatter: this.headerFormatter,
sort: true,
filter: selectFilter({
placeholder: 'Category 2...',
options: this.getCategory2()
})
},
{ dataField: 'category_3',
text: 'category_3',
headerFormatter: this.headerFormatter,
sort: true,
filter: selectFilter({
placeholder: 'Category 3...',
options: this.getCategory3()
})
}
]
So is there an easy way of having the options default to the different values in the dataFields and if not, how can I access the filtered data that is currently displayed and use those as base for the options in those filters.
Appreciate your help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)

Top Related StackOverflow Question
I actually found a work around. However, I am still curious why the above happens when following your guidelines… Did something change?
Also more general question: Is the onFilter function not called if I pick the “all value” / “placeholder” value? I think I need that in order to reset the options.
Or if anyone has a better idea, please let me know how I can achieve the dynamic options for select filters.
Keep up the great work!
Cheers, Remo
This was very helpful, as I wasn’t aware of the exposed API… So I did what you suggested and it works just fine. Thanks a lot Allen!