[英]React component Ag-grid filterChangedCallback does not trigger doesFilterPass
I am attempting to programmatically cause a filter to run doesFilterPass on component load. 我试图以编程方式导致筛选器在组件加载时运行dosFilterPass。 So far I've tried adding filterChangedCallback to componentWillMount, componentDidMount, componentWillUpdate and componentDidUpdate calls.
到目前为止,我已经尝试将filterChangedCallback添加到componentWillMount,componentDidMount,componentWillUpdate和componentDidUpdate调用中。 However none of these calls trigger doesFilterPass.
但是,这些调用均不会触发dosFilterPass。 Triggering the filterChangedCallback from the gui, with event handlers like onChange does work.
使用事件处理程序(如onChange)从gui触发filterChangedCallback确实起作用。 Is this a bug?
这是错误吗? Does anyone know how to consistently get doesFilterPass to run?
有谁知道如何一致地使didFilterPass运行?
I spoke to the guys at ag-grid. 我和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.
因此,我最终在componentDidUpdate处理程序之外使用了300毫秒的计时器来调用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. 我遇到了同样的问题,因此我从此处下载了一个示例react代码示例ag-grid-react-example并阅读了代码。
Try to call filterChangedCallback() in this.SetState like this: 尝试像这样在this.SetState中调用filterChangedCallback() :
this.setState({stateList}, this.props.filterChangedCallback);
It worked for me. 它为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.