diff --git a/projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts b/projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts index 7425dce6067..c978b6e6a1f 100644 --- a/projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts +++ b/projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts @@ -306,9 +306,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy { const anyFiltered = this.esf.listData.some(i => i.isFiltered); const anyUnfiltered = this.esf.listData.some(i => !i.isFiltered); - if (anyFiltered && anyUnfiltered) { - searchAllBtn.indeterminate = true; - } + searchAllBtn.indeterminate = anyFiltered && anyUnfiltered; this.esf.listData.forEach(i => i.isSelected = i.isFiltered); this.displayedListData = this.esf.listData; diff --git a/projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts b/projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts index 870c43f97d0..95685cbc2c8 100644 --- a/projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts +++ b/projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts @@ -605,7 +605,7 @@ export class IgxGridExcelStyleFilteringComponent extends BaseFilteringComponent if (operand instanceof FilteringExpressionsTree) { const columnExprTree = operand as FilteringExpressionsTree; if (columnExprTree.fieldName === this.column.field) { - break; + continue; } } expressionsTree.filteringOperands.push(operand); diff --git a/projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts b/projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts index 895428e3b3b..26df911497d 100644 --- a/projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts +++ b/projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts @@ -168,15 +168,13 @@ export class IgxFilteringService implements OnDestroy { const filteringIgnoreCase = ignoreCase || (col ? col.filteringIgnoreCase : false); const filteringTree = grid.filteringExpressionsTree; - const columnFilteringExpressionsTree = grid.filteringExpressionsTree.find(field) as IFilteringExpressionsTree; + const columnFilteringExpressionsTree = filteringTree.find(field) as IFilteringExpressionsTree; conditionOrExpressionTree = conditionOrExpressionTree ?? columnFilteringExpressionsTree; const fieldFilterIndex = filteringTree.findIndex(field); - if (fieldFilterIndex > -1) { - filteringTree.filteringOperands.splice(fieldFilterIndex, 1); - } + const newFilteringTree: FilteringExpressionsTree = this.prepare_filtering_expression(filteringTree, field, value, conditionOrExpressionTree, - filteringIgnoreCase, fieldFilterIndex, true); + filteringIgnoreCase, fieldFilterIndex, true); const eventArgs: IFilteringEventArgs = { owner: grid, @@ -522,12 +520,11 @@ export class IgxFilteringService implements OnDestroy { if (fieldFilterIndex > -1) { filteringTree.filteringOperands.splice(fieldFilterIndex, 1); } - this.prepare_filtering_expression(filteringTree, fieldName, term, conditionOrExpressionsTree, ignoreCase, fieldFilterIndex); grid.filteringExpressionsTree = filteringTree; } - /** Modifies the filteringState object to contain the newly added fitering conditions/expressions. + /** Modifies the filteringState object to contain the newly added filtering conditions/expressions. * If createNewTree is true, filteringState will not be modified (because it directly affects the grid.filteringExpressionsTree), * but a new object is created and returned. */ @@ -540,7 +537,6 @@ export class IgxFilteringService implements OnDestroy { insertAtIndex = -1, createNewTree = false): FilteringExpressionsTree { - const oldExpressionsTreeIndex = filteringState.findIndex(fieldName); const expressionsTree = conditionOrExpressionsTree instanceof FilteringExpressionsTree ? conditionOrExpressionsTree as IFilteringExpressionsTree : null; const condition = conditionOrExpressionsTree instanceof FilteringExpressionsTree ? @@ -550,20 +546,18 @@ export class IgxFilteringService implements OnDestroy { const newExpressionsTree: FilteringExpressionsTree = createNewTree ? new FilteringExpressionsTree(filteringState.operator, filteringState.fieldName) : filteringState as FilteringExpressionsTree; - if (oldExpressionsTreeIndex === -1) { - // no expressions tree found for this field - if (expressionsTree) { - if (insertAtIndex > -1) { - newExpressionsTree.filteringOperands.splice(insertAtIndex, 0, expressionsTree); - } else { - newExpressionsTree.filteringOperands.push(expressionsTree); - } - } else if (condition) { - // create expressions tree for this field and add the new expression to it - const newExprTree: FilteringExpressionsTree = new FilteringExpressionsTree(filteringState.operator, fieldName); - newExprTree.filteringOperands.push(newExpression); - newExpressionsTree.filteringOperands.push(newExprTree); + // no expressions tree found for this field + if (expressionsTree) { + if (insertAtIndex > -1) { + newExpressionsTree.filteringOperands[insertAtIndex] = expressionsTree; + } else { + newExpressionsTree.filteringOperands.push(expressionsTree); } + } else if (condition) { + // create expressions tree for this field and add the new expression to it + const newExprTree: FilteringExpressionsTree = new FilteringExpressionsTree(filteringState.operator, fieldName); + newExprTree.filteringOperands.push(newExpression); + newExpressionsTree.filteringOperands.push(newExprTree); } return newExpressionsTree; @@ -580,7 +574,7 @@ export class IgxFilteringService implements OnDestroy { if (expressionsTree.operator === FilteringLogic.Or) { const andOperatorsCount = this.getChildAndOperatorsCount(expressionsTree); - // having more that 'And' and operator in the sub-tree means that the filter could not be represented without parentheses. + // having more than one 'And' operator in the sub-tree means that the filter could not be represented without parentheses. return andOperatorsCount > 1; } diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts index c6f90a16ba3..6d6e1ac3cc1 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts @@ -47,9 +47,9 @@ import { import { GridSelectionMode, FilterMode } from '../common/enums'; import { ControlsFunction } from '../../test-utils/controls-functions.spec'; import { FormattedValuesFilteringStrategy } from '../../data-operations/filtering-strategy'; -import { IgxCalendarComponent } from '../../calendar/calendar.component'; import { IgxInputGroupComponent } from '../../input-group/public_api'; import { formatDate } from '../../core/utils'; +import { IgxCalendarComponent } from '../../calendar/calendar.component'; const DEBOUNCETIME = 30; const FILTER_UI_ROW = 'igx-grid-filtering-row'; @@ -4348,8 +4348,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => { tick(100); fix.detectChanges(); verifyExcelStyleFilterAvailableOptions(fix, - ['Select All', '(Blanks)', 'False', 'True'], - [null, true, true, false]); + ['Select All', '(Blanks)', 'False'], + [true, true, true]); GridFunctions.clickExcelFilterIcon(fix, 'ProductName'); tick(100);