react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Show filter text boxes and set default filtering values in filter text boxes when initializing

Open sahil37 opened this issue 9 years ago • 16 comments

WHICH VERSION OF REACT ARE YOU USING?

Officially Supported:
[ ] v0.14.x
Community Supported:
[ x] v15.0.x

WHICH BROWSER ARE YOU USING?

Officially Supported:
[ ] IE 9 / IE 10 / IE 11
[ ] Edge
[ x] Chrome
Should work:
[ ] Firefox
[ ] Safari

I'm submitting a ... (check one with "x")

[ ] bug report
[x ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md

Current behavior

There is no way at the moment to show the filter boxes for each column by default on initialization without the user having the click on the filter rows button. Additionally there is no way to set default filter values for the filter boxes for each column.

Expected/desired behavior

A way to show the filter boxes for each column by default on initialization as well as populate these filter boxes for each column with initial values.

What is the motivation / use case for changing the behavior?

I am saving the filter values entered by the user on the back-end and I want to use them to repopulate the filter text boxes when the component is initialized again.

sahil37 avatar Feb 19 '17 13:02 sahil37

My workaround to show filters:

    componentDidMount() {
        this.grid.onToggleFilter();
    }
    render() {
         return (
         <ReactDataGrid
                ref={(grid) => { this.grid = grid; }}

dsego avatar Feb 19 '17 19:02 dsego

componentDidMount() {
  this.refs.dataGrid.setState({canFilter: true}, () => this.hideFilterButton())
}

hideFilterButton = () => $('div.react-grid-Toolbar .tools button.btn').hide();

works for me

jarongao avatar Feb 23 '17 22:02 jarongao

+1 for having the ability to set default values for filters at initialization.

mathieuripert avatar Mar 24 '17 15:03 mathieuripert

+1 for having the ability to set default values for filters at initialization or from any funcation

Prashant89Chaudhary avatar Apr 19 '17 06:04 Prashant89Chaudhary

Any update or workaround for this.

Prashant89Chaudhary avatar May 21 '17 10:05 Prashant89Chaudhary

+1

bostondevin avatar Jul 19 '17 17:07 bostondevin

Here's my workaround. In this case, I know the order of my columns never change, so I used the element selector in dev tools to find the input i wanted to set default to and voila.

componentDidMount() {
		this.grid.onToggleFilter();
		setTimeout(function () {
			document.getElementsByClassName("form-control")[2].value = "false";
		}, 250);
	}

KevinMongiello avatar Oct 17 '17 00:10 KevinMongiello

@sahil37, @KevinMongiello Any update or workaround for this. I want to show some default filter text, especially for the multi-select filter. I keep my filtering logic on the server side. So, I am getting the right results. I just need to set the filter values/text in the Filter controls. Please update if there is a work around for this.

Thanks, Madhan

madhan-dhamodaran avatar Mar 08 '18 22:03 madhan-dhamodaran

Currently RDG does not seem to support showing the filter by default and @dsego solution seems like a good workaround.

To show some default filter text, custom filters can be used. Something like the following should do the trick

filterRenderer: (props) => <CustomFilter initialFilterTerm="value" {...props} />

In the CustomFilter initialFilterTerm can be used to set the initial state

amanmahajan7 avatar Mar 11 '18 22:03 amanmahajan7

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please reopen this if you feel it has been incorrectly closed and we will do our best to look into it. Thank you for your contributions.

stale[bot] avatar Jul 12 '18 12:07 stale[bot]

@amanmahajan7,

I have finished adding this and ready to raise a PR. I have been trying to get in touch with a you guys through email, slack etc., but in vain.

Not sure how to reopen this issue. But, this issue is valid and I will be raising a PR before this weekend

madhan-dhamodaran avatar Jul 12 '18 13:07 madhan-dhamodaran

Up so the bot won't close ;)

Antonhansel avatar Jul 25 '18 22:07 Antonhansel

Would be very interested in the capability to set default filter values through a function for the table

bhanu52004 avatar Aug 02 '18 02:08 bhanu52004

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please reopen this if you feel it has been incorrectly closed and we will do our best to look into it. Thank you for your contributions.

stale[bot] avatar Sep 01 '18 02:09 stale[bot]

How can we do this in a functional component like the examples??

ghost avatar Aug 08 '19 19:08 ghost

+1 How (the hell ;-)) is it possible not to have any way to display by default filters columns without activating this ugly toolbar...

dngconsulting avatar Oct 07 '19 13:10 dngconsulting