I have a react app and everything seems to work fine. I want to add an additional piece of functionality with filtering although I'm currently stuck.
Can anyone provide some advice on how to preset the filter
using the example filtering method I've seen in this article I've tried to implement a basic example although it doesn't work
this.state = {
gridOptions: {
.
.
.
onGridReady: this.initialFilter
},
initialFilter(){
tmp = {Currency: {type: 'contains', filter: 'usd'}};
this.state.gridOptions.api.setFilterModel(tmp);
this.state.gridOptions.api.onFilterChanged();
}
What I expected from running this is the Currency column would be filtered for condition containing filter text usd
================================================= edit: after trying
initialFilter(){
let hi=this.state.gridOptions.api.getFilterInstance('Currency');
hi.setType('contains');
hi.setFilter('usd');
hi.onFilterChanged();
}
Nothing happens + no error
but when i add the code in an existing method for changing filters (when i manually add a filter):
onAfterFilterChanged() {
let hi=this.state.gridOptions.api.getFilterInstance('Currency');
hi.setType('contains');
hi.setFilter('usd');
hi.onFilterChanged();
this.setState({
rowsToDisplay: this.state.gridOptions.api.filterManager.rowModel.rowsToDisplay.length,
filtering: this.props.report.views.filters
});
this.props.filterme(this.state.filtering);
}
then i get the below error
Full error: Uncaught RangeError: Maximum call stack size exceeded
at RowRenderer.workOutFirstAndLastRowsToRender (dme-ui-buidle.js:13181)
at RowRenderer.drawVirtualRows (dme-ui-buidle.js:13178)
at RowRenderer.refreshAllVirtualRows (dme-ui-buidle.js:13138)
at RowRenderer.refreshView (dme-ui-buidle.js:13034)
at RowRenderer.onModelUpdated (dme-ui-buidle.js:12979)
at RowRenderer.onPageLoaded (dme-ui-buidle.js:12931)
at dme-ui-buidle.js:2684
at Array.forEach (<anonymous>)
at EventService.dispatchEvent (dme-ui-buidle.js:2683)
at PaginationProxy.onModelUpdated (dme-ui-buidle.js:27264)