question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CustomFilter documentation not clear for actually filtering cell values

See original GitHub issue

Hi 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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
charlieansteycommented, Aug 22, 2017

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 and

trigger filtering

as 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.

0reactions
marcramsercommented, Jul 27, 2018

@AllenFang But if you return true/false in the callback, you will not be able to get the value in the afterColumnFilter().

  afterColumnFilter = (filterConds, result) => {
    for (const prop in filterConds) {
      if (filterConds[prop].type === 'CustomFilter') {
        console.log('Filter column= ' + prop + ', Filter value= ' + filterConds[prop].value.callback());
      } else {
       // normal way to get the value
        console.log('Filter column= ' + prop + ', Filter value= ' + filterConds[prop].value);
      }
    }
  };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter data in a range or table
Once you filter data in a range of cells or table, you can either reapply a filter to get up-to-date results, or clear...
Read more >
SpreadProcessing - Filtering - Telerik Document Processing
The custom filter is a filter which contains one or two critera which are used to filter the column to which the filter...
Read more >
Excel Filter: How to add, use and remove
To filter out blanks, i.e. display non-blank cell, click the auto-filter arrow, make sure the (Select All) box is checked, and then clear...
Read more >
Excel VBA Autofilter: A Complete Guide with Examples
In this Excel tutorial, you;'l learn how to use the VBA Autofilter method in Excel to automate the process of filtering data.
Read more >
Adding text filters - Amazon QuickSight
Custom filter – With this option, you enter a single value that the field value must match in some way. You can specify...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found