简体   繁体   中英

React component Ag-grid filterChangedCallback does not trigger doesFilterPass

I am attempting to programmatically cause a filter to run doesFilterPass on component load. So far I've tried adding filterChangedCallback to componentWillMount, componentDidMount, componentWillUpdate and componentDidUpdate calls. However none of these calls trigger doesFilterPass. Triggering the filterChangedCallback from the gui, with event handlers like onChange does work. Is this a bug? Does anyone know how to consistently get doesFilterPass to run?

I spoke to the guys at ag-grid. They call this a limitation of the control. So I ended up using a timer off of the componentDidUpdate handler for 300 milliseconds to call filterChangedCallback. That's a terrible solution but it works.

I had the same problem, so I downloaded a sample react code from here ag-grid-react-example and read code.

Try to call filterChangedCallback() in this.SetState like this:

this.setState({stateList}, this.props.filterChangedCallback);

It worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM