-
Notifications
You must be signed in to change notification settings - Fork 379
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
Multiple filters for Griddle v1 #630
Comments
This is also of great interest to me, I've been trying to figure out how to add multiple filters from a plugin I've made, but I don't see any obvious ways of doing so. It appears that the core functionality only allows one filter at a time. Also column based filtering would be amazing. |
I think this is a must have and looking forward to see how to plug-in into my griddle table. Anyone with some working example? Related? |
I've added by the way a modification in my forked repo in a way I can provide to a custom Please any suggestion, enhancement or doubt, let's discuss it. Therefore my custom Filter component: class CustomFilter extends Component {
constructor(props) {
/* ... */
this.state = {
filter1: '',
filter2: ''
};
}
setFilter1(e) {
this.setState({
filter1: e.target.value
}, () => {
this.props.setFilter({
filter1: this.state.filter1
});
});
}
setFilter2(e) {
this.setState({
filter2: e.target.value
}, () => {
this.props.setFilter({
filter2: this.state.filter2
});
});
}
render() {
return (
<div className="custom__filters">
<input
type="text"
name="filter"
placeholder="Filter 1"
value={this.state.filter1}
onChange={this.setFilter1}
style={this.props.style}
className={cx(this.props.className, 'custom-filters__filter')} />
<input
type="text"
name="filter"
placeholder="Filter 2"
value={this.state.filter2}
onChange={this.setFilter2}
style={this.props.style}
className={cx(this.props.className, 'custom-filters__filter')} />
</div>
);
}
}
CustomFilter.propTypes = {
/* ... */
};
export default CustomFilter; The export const filteredDataSelector = createSelector(
dataSelector,
filterSelector,
(data, filter) => {
return data.filter(row => {
return Object.keys(row.toJSON())
.some(key => {
if (typeof filter === 'string') {
return row.get(key) && row.get(key).toString().toLowerCase().indexOf(filter.toLowerCase()) > -1
}
return row.get(key) && typeof filter[key] === 'string' && row.get(key).toString().toLowerCase().indexOf(filter[key].toLowerCase()) > -1;
})
})
}
); |
Thanks so much for this! I'll give it a try and report back. |
Any update on being able to filter by column? I'm catching the |
Is there a working example showing how to implement multiple filters for Griddle v.1, as was shown in the v. 0.x docs https://griddlegriddle.github.io/v0-docs/customization.html ?
The text was updated successfully, but these errors were encountered: