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.

Clear more than one column filters at a time works in a weird way

See original GitHub issue

First of all, thanks @AllenFang for this amazing work. It is helping us a lot.

I’m working with version “react-bootstrap-table2-filter”: “0.1.6” and trying to create a clear button to filter all values on my table. Looking at this example I decided to follow it and set empty value instead of 0 in order to clear the filter and it worked!!

But when I tried to applied same logic to all my columns, I got an error. My second try was to create a new variable so that every column would have its own method that clear the filter. That worked better. My clear button was cleaning both text boxes, and the last column was cleaned. However the first one showed the values of the filters without any filter at the top.

I must also say that even if the table shows a weird status, first column with the values of the filter without having a value at the top, if I try to filter by another value, it works.

Here is part of my code:

let nameFilter,orgFilter;
const clearInfo = () => {
	nameFilter('');
	orgFilter('');
};

const columns = [{
	dataField: 'Value1',
	text: 'Value1',
	sort: true,
	filter: textFilter({
		getFilter: (filter) => {
			nameFilter = filter;
		}
	})
},{
	dataField: 'Value2',
	text: 'Value2',
	sort: true,
	filter: textFilter({
		getFilter: (filter) => {
			orgFilter = filter;
		}
	})
}

//more columns I need to be cleared too

];

//more code .....
<Button bsStyle="primary" bsSize="small" onClick={ clearInfo }>Clear Filters</Button>

Thanks!!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
agarciaffdccommented, May 15, 2018

Thanks @AllenFang !! This new version works!!

In order to help others, let you also know that my code only worked locally. I made few changes in order to make it work on our production enviroment.

class Subscriber extends Component {

	constructor(props) {
		super(props);
		this.state = {
			column1Filter: '',
			column2Filter: '',
		};
	}

	// ...

	render() {
		
		const clearInfo = () => {
			this.setState.column1Filter('');
			this.setState.column2Filter('');
		};

		const columns = [{
			dataField: 'Value1',
			text: 'Value1',
			sort: true,
			filter: textFilter({
				getFilter: (filter) => {
					this.setState.column1Filter = filter;
				}
			})
		},{
			dataField: 'Value2',
			text: 'Value2',
			sort: true,
			filter: textFilter({
				getFilter: (filter) => {
					this.setState.column2Filter = filter;
				}
			})
		}

		//more columns I need to be cleared too

		];

		//....

		<Button bsStyle="primary" bsSize="small" onClick={ clearInfo }>Clear Filters</Button>	

		// ...
	}

	//....
}

Thanks!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reapply a filter and sort, or clear a filter - Microsoft Support
To reapply a filter or sort, on the Home tab, in the Editing group, click Sort & Filter, and then click Reapply. Top...
Read more >
Video: Advanced filter details - Microsoft Support
Click the Filter icon button next to the column heading, and then click Clear Filter from <“ Column Name”>. Remove all the filters...
Read more >
Clear or remove a filter - Microsoft Support
Clear all the filters in a worksheet. Click the Data tab, and then click Clear. Clear a filter button. How do I know...
Read more >
How to Clear Filter in Excel? - Earn & Excel
Clearing All the Filters at Once · First, go to the “Data” tab on the ribbon and locate the “Sort and Filter” group....
Read more >
Excel 2013: Filtering Data - GCFGlobal
After applying a filter, you may want to remove—or clear—it from your worksheet so you'll be able to filter content in different ways....
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