Skip to content

Commit

Permalink
fix(filter): refreshTreeDataFilters only when Tree is enabled
Browse files Browse the repository at this point in the history
- also make sure DataView object exist before trying to get items array
  • Loading branch information
ghiscoding committed Jul 14, 2021
1 parent 85f028e commit 07c70d5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/common/src/services/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@ export class FilterService {
});

// when we have a Filter Presets on a Tree Data View grid, we need to call the pre-filtering of tree data
this.refreshTreeDataFilters();
if (this._gridOptions?.enableTreeData) {
this.refreshTreeDataFilters();
}
}
return this._columnDefinitions;
}
Expand All @@ -728,7 +730,7 @@ export class FilterService {
* @param {Array<Object>} [items] - optional flat array of parent/child items to use while redoing the full sort & refresh
*/
refreshTreeDataFilters(items?: any[]) {
const inputItems = items ?? this._dataView.getItems() ?? [];
const inputItems = items ?? this._dataView?.getItems?.() ?? [];

if (this._dataView && this._gridOptions?.enableTreeData && inputItems.length > 0) {
this._tmpPreFilteredData = this.preFilterTreeData(inputItems, this._columnFilters);
Expand Down Expand Up @@ -917,7 +919,9 @@ export class FilterService {
});

// when using Tree Data, we also need to refresh the filters because of the tree structure with recursion
this.refreshTreeDataFilters();
if (this._gridOptions?.enableTreeData) {
this.refreshTreeDataFilters();
}

this._dataView.refresh();
}
Expand Down

0 comments on commit 07c70d5

Please sign in to comment.