@@ -16,13 +16,14 @@ import {
1616 IgxGridExternalAdvancedFilteringComponent ,
1717 IgxGridAdvancedFilteringBindingComponent ,
1818 IgxGridAdvancedFilteringOverlaySettingsComponent ,
19- IgxGridAdvancedFilteringDynamicColumnsComponent
19+ IgxGridAdvancedFilteringDynamicColumnsComponent ,
20+ IgxGridAdvancedFilteringWithToolbarComponent
2021} from '../../test-utils/grid-samples.spec' ;
2122import { ControlsFunction } from '../../test-utils/controls-functions.spec' ;
2223import { FormattedValuesFilteringStrategy } from '../../data-operations/filtering-strategy' ;
2324import { IgxHierGridExternalAdvancedFilteringComponent } from '../../test-utils/hierarchical-grid-components.spec' ;
2425import { IgxHierarchicalGridComponent } from '../hierarchical-grid/public_api' ;
25- import { IFilteringEventArgs } from '../public_api' ;
26+ import { IFilteringEventArgs , IgxGridToolbarAdvancedFilteringComponent , IgxGridToolbarComponent } from '../public_api' ;
2627import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
2728import { By } from '@angular/platform-browser' ;
2829import { IgxDateTimeEditorDirective } from '../../directives/date-time-editor/date-time-editor.directive' ;
@@ -43,7 +44,8 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
4344 IgxGridExternalAdvancedFilteringComponent ,
4445 IgxGridAdvancedFilteringBindingComponent ,
4546 IgxHierGridExternalAdvancedFilteringComponent ,
46- IgxGridAdvancedFilteringDynamicColumnsComponent
47+ IgxGridAdvancedFilteringDynamicColumnsComponent ,
48+ IgxGridAdvancedFilteringWithToolbarComponent
4749 ]
4850 } ) ;
4951 } ) ) ;
@@ -1938,7 +1940,7 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
19381940 verifyChildrenSelection ( GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 1 ] ) , false ) ;
19391941 } ) ) ;
19401942
1941-
1943+
19421944 it ( 'Should remove all empty groups when clicking `delete` on a group\'s operator line\'s context menu.' , fakeAsync ( ( ) => {
19431945 // Apply advanced filter through API.
19441946 const rootTree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
@@ -3178,6 +3180,65 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
31783180
31793181 } ) ;
31803182
3183+ describe ( 'Advanced filtering with toolbar' , ( ) => {
3184+ let fix : ComponentFixture < IgxGridAdvancedFilteringWithToolbarComponent > ;
3185+ let grid : IgxGridComponent ;
3186+
3187+ beforeEach ( fakeAsync ( ( ) => {
3188+ fix = TestBed . createComponent ( IgxGridAdvancedFilteringWithToolbarComponent ) ;
3189+ grid = fix . componentInstance . grid ;
3190+ fix . detectChanges ( ) ;
3191+ } ) ) ;
3192+
3193+ it ( 'Should update toolbar when advancedFilteringExpressionsTreeChange emits a new value' , fakeAsync ( ( ) => {
3194+ // Set initial filtering expressions tree
3195+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
3196+ tree . filteringOperands . push ( {
3197+ fieldName : 'ProductName' ,
3198+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
3199+ searchVal : 'angular' ,
3200+ ignoreCase : true
3201+ } ) ;
3202+
3203+ // Apply the initial filtering tree
3204+ grid . advancedFilteringExpressionsTree = tree ;
3205+ fix . detectChanges ( ) ;
3206+
3207+ // Create a new filtering tree with more filters
3208+ const updatedTree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
3209+ updatedTree . filteringOperands . push ( {
3210+ fieldName : 'Downloads' ,
3211+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
3212+ searchVal : 10 ,
3213+ ignoreCase : true
3214+ } ) ;
3215+ updatedTree . filteringOperands . push ( {
3216+ fieldName : 'ProductName' ,
3217+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
3218+ searchVal : 'angular' ,
3219+ ignoreCase : true
3220+ } ) ;
3221+ updatedTree . filteringOperands . push ( {
3222+ fieldName : 'Category' ,
3223+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
3224+ searchVal : 'electronics' ,
3225+ ignoreCase : false
3226+ } ) ;
3227+
3228+ // Update the filtering expressions tree
3229+ grid . advancedFilteringExpressionsTree = updatedTree ;
3230+ fix . detectChanges ( ) ;
3231+
3232+ // Verify the correct number of filters
3233+ const toolbarDebugElement = fix . debugElement . query ( By . directive ( IgxGridToolbarAdvancedFilteringComponent ) ) ;
3234+ const toolbarComponent = toolbarDebugElement . componentInstance as IgxGridToolbarAdvancedFilteringComponent ;
3235+ const numberOfFilters = ( toolbarComponent as any ) . numberOfColumns ;
3236+
3237+ expect ( grid . advancedFilteringExpressionsTree . filteringOperands . length ) . toEqual ( 3 ) ;
3238+ expect ( numberOfFilters ) . toEqual ( 3 ) ;
3239+ } ) ) ;
3240+ } )
3241+
31813242 describe ( 'Localization - ' , ( ) => {
31823243 it ( 'Should correctly change resource strings for Advanced Filtering dialog.' , fakeAsync ( ( ) => {
31833244 const fix = TestBed . createComponent ( IgxGridAdvancedFilteringComponent ) ;
0 commit comments