CustomFilter documentation not clear for actually filtering cell values
See original GitHub issueHi Allen,
Firstly thanks for the awesome package, it works a treat in a project I’ve been working on for many months.
Just getting into custom filtering, trying to filter a column holding a date value with a from/to date range. Having looked at #601 and the various examples, I know DateFilter only supports a single date and comparator.
So having gone through https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/custom-filter.js and tried mocking up a basic solution, I can’t see how/where I would filter the cell
value? This example doesn’t appear to actually filter - it just calls this.props.filterHandler()
which when followed in debugging, goes into handleFilter
and further into the internal Filter
class etc.
How do I specify a custom function which is given the column value for each row and applies the filtering itself? I don’t want to start using remote
in any serious way as the table does the job just fine otherwise. And the handleFilterData
API method seems to only support the built-in filters.
Look forward to hearing back, Charlie
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hi Allen. Sorry for my similarly late response!
Okay so I don’t think this answers my question. Calling
handleFilter
lets me pass a value to your pre-defined filter function andas you say. But that actual filtering isn’t customisable - I can’t for example filter the value where it is outside a range of 2 values or dates. As stated, I want to handle the filtering myself. So I want to filter a date column between 2 dates which I define.
In the programmatic examples you’ve given, again that doesn’t appear to let me filter between 2 dates or indeed anything else custom.
I get the feeling what I’m asking for isn’t possible in
react-bootstrap-table
at the moment, essentially I’m saying the filter function should be exposed as a prop to pass in. Your custom filter feature doesn’t appear to allow me to do what I expect: provide a custom function as a prop which accepts the column value and returns true/false to indicate whether or not the column value/row passed should be filtered. To me at least, the custom filter feature doesn’t actually let me do custom filtering on the column - it just lets me customise when the filtering is triggered, but the filtering itself is just one of the predefined types you’ve implemented.Again, I’m hoping this is just my lack of understanding of the documented examples and that I’m wrong. Hopefully you can shed some light on it.
@AllenFang But if you return true/false in the callback, you will not be able to get the value in the afterColumnFilter().