Posted 11 May 2018, 2:27 am EST
Hello,
I have implemented the filter definition preserve for a grid inside AngularJS component. This Grid is filled from collection after getting data from an API call like,
dataService.getData().then(function (result) {
this.dataSource = new wijmo.collections.CollectionView(result.data);
}
I am using an API to store the filter definition data, though this data is already fetched and stored in local variable. And I have added control ‘flexGrid’ in html wijmo. For adding the filter, I have tried putting the below code under the dataSource collection, but the filter is cleared due to itemsSourceChanged event handler for filter clear. Even I tried, adding the code in the grid initialized handler and itemsSourceChanged grid event handler, but it behaved in same way.
```
this.flexFilter = new wijmo.grid.filter.FlexGridFilter(this.flexGrid);
this.flexFilter.filterColumns = that.filterColumns;
var filterDefinition = apiService.getFilter(); if (angular.isDefined(filterDefinition)) { that.flexFilter.filterDefinition = filterDefinition; } that.flexFilter.filterApplied.addHandler(function () { apiService.setFilter(that.flexFilter.filterDefinition); });
I tried removing the handler, but this is removing the handler:
that.flexGrid.itemsSourceChanged.removeHandler(that.flexGrid.clear);
Then I also tried it by this way:
```
var index = that.flexGrid.itemsSourceChanged._handlers.findIndex(function (handler) {
return handler.self === undefined;
});
that.flexGrid.itemsSourceChanged._handlers.splice(index, 1);
By doing this the filter is preserved, but when setting the filter from UI, it shows the filtered column data. So, I am not able to revert the filters by unsetting the data. Even clear button is not working.
Can someone help me with this?
Thanks,
Brijesh
