@@ -16,12 +16,13 @@ import {
16
16
IgxGridExternalAdvancedFilteringComponent ,
17
17
IgxGridAdvancedFilteringBindingComponent ,
18
18
IgxGridAdvancedFilteringDynamicColumnsComponent ,
19
- IgxGridAdvancedFilteringSerializedTreeComponent
19
+ IgxGridAdvancedFilteringSerializedTreeComponent ,
20
+ IgxGridAdvancedFilteringWithToolbarComponent
20
21
} from '../../test-utils/grid-samples.spec' ;
21
22
import { FormattedValuesFilteringStrategy } from '../../data-operations/filtering-strategy' ;
22
23
import { IgxHierGridExternalAdvancedFilteringComponent } from '../../test-utils/hierarchical-grid-components.spec' ;
23
24
import { IgxHierarchicalGridComponent } from '../hierarchical-grid/public_api' ;
24
- import { IFilteringEventArgs } from '../public_api' ;
25
+ import { IFilteringEventArgs , IgxGridToolbarAdvancedFilteringComponent } from '../public_api' ;
25
26
import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
26
27
import { QueryBuilderFunctions } from '../../query-builder/query-builder-functions.spec' ;
27
28
import { By } from '@angular/platform-browser' ;
@@ -38,7 +39,8 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
38
39
IgxGridExternalAdvancedFilteringComponent ,
39
40
IgxGridAdvancedFilteringBindingComponent ,
40
41
IgxHierGridExternalAdvancedFilteringComponent ,
41
- IgxGridAdvancedFilteringDynamicColumnsComponent
42
+ IgxGridAdvancedFilteringDynamicColumnsComponent ,
43
+ IgxGridAdvancedFilteringWithToolbarComponent
42
44
]
43
45
} ) ;
44
46
} ) ) ;
@@ -1195,6 +1197,65 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
1195
1197
} ) ) ;
1196
1198
} ) ;
1197
1199
1200
+ describe ( 'Advanced filtering with toolbar' , ( ) => {
1201
+ let fix : ComponentFixture < IgxGridAdvancedFilteringWithToolbarComponent > ;
1202
+ let grid : IgxGridComponent ;
1203
+
1204
+ beforeEach ( fakeAsync ( ( ) => {
1205
+ fix = TestBed . createComponent ( IgxGridAdvancedFilteringWithToolbarComponent ) ;
1206
+ grid = fix . componentInstance . grid ;
1207
+ fix . detectChanges ( ) ;
1208
+ } ) ) ;
1209
+
1210
+ it ( 'Should update toolbar when advancedFilteringExpressionsTreeChange emits a new value' , fakeAsync ( ( ) => {
1211
+ // Set initial filtering expressions tree
1212
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1213
+ tree . filteringOperands . push ( {
1214
+ fieldName : 'ProductName' ,
1215
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1216
+ searchVal : 'angular' ,
1217
+ ignoreCase : true
1218
+ } ) ;
1219
+
1220
+ // Apply the initial filtering tree
1221
+ grid . advancedFilteringExpressionsTree = tree ;
1222
+ fix . detectChanges ( ) ;
1223
+
1224
+ // Create a new filtering tree with more filters
1225
+ const updatedTree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1226
+ updatedTree . filteringOperands . push ( {
1227
+ fieldName : 'Downloads' ,
1228
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
1229
+ searchVal : 10 ,
1230
+ ignoreCase : true
1231
+ } ) ;
1232
+ updatedTree . filteringOperands . push ( {
1233
+ fieldName : 'ProductName' ,
1234
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1235
+ searchVal : 'angular' ,
1236
+ ignoreCase : true
1237
+ } ) ;
1238
+ updatedTree . filteringOperands . push ( {
1239
+ fieldName : 'Category' ,
1240
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
1241
+ searchVal : 'electronics' ,
1242
+ ignoreCase : false
1243
+ } ) ;
1244
+
1245
+ // Update the filtering expressions tree
1246
+ grid . advancedFilteringExpressionsTree = updatedTree ;
1247
+ fix . detectChanges ( ) ;
1248
+
1249
+ // Verify the correct number of filters
1250
+ const toolbarDebugElement = fix . debugElement . query ( By . directive ( IgxGridToolbarAdvancedFilteringComponent ) ) ;
1251
+ const toolbarComponent = toolbarDebugElement . componentInstance as IgxGridToolbarAdvancedFilteringComponent ;
1252
+ const numberOfFilters = ( toolbarComponent as any ) . numberOfColumns ;
1253
+
1254
+ expect ( grid . advancedFilteringExpressionsTree . filteringOperands . length ) . toEqual ( 3 ) ;
1255
+ expect ( numberOfFilters ) . toEqual ( 3 ) ;
1256
+ } ) ) ;
1257
+ } )
1258
+
1198
1259
describe ( 'Localization - ' , ( ) => {
1199
1260
it ( 'Should correctly change resource strings for Advanced Filtering dialog.' , fakeAsync ( ( ) => {
1200
1261
const fix = TestBed . createComponent ( IgxGridAdvancedFilteringComponent ) ;
0 commit comments