Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column Filter in react-bootstrap-table-next not working? #2120

Open
hirocsingh opened this issue Jul 30, 2020 · 1 comment
Open

Column Filter in react-bootstrap-table-next not working? #2120

hirocsingh opened this issue Jul 30, 2020 · 1 comment

Comments

@hirocsingh
Copy link

hirocsingh commented Jul 30, 2020

I have following widgets which represents categories form the data in the table: enter image description here

The flow is when a user clicks on one of the widgets the table should show data of that category only.

So far I have implemented following:

const columns = [
{ 
 ....
 dataField: "Category", 
 formatter: formatCategory,
 text: "Category",
 sort: true,
 filter: textFilter({
   getFilter: (filter) => {
     // nameFilter was assigned once the component has been mounted.
     categoryFilter = filter;
   }
 })
 ....
}

Handle Clicking Event on Button and Passing the category:

const handleWidgetClick = (category) => {
   categoryFilter = category;

   // When I am doing something like this I am getting Uncaught Error
   // categoryFilter is not a Function
   categoryFilter(category) 
};

I have followed example from here

I am not sure what/where I am doing something wrong. Please guide me through it, Thanks

@julienmouraddotcom
Copy link

@hirocsingh , you're overriding your categoryFilter function when you do categoryFilter = category. It's no longer a function but a string instead (assuming this is what you're passing when you click on the button).

You just need to do:

const handleWidgetClick = (category) => {
   categoryFilter(category) 
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants