@@ -2507,5 +2507,77 @@ describe('IgxPivotGrid #pivotGrid', () => {
2507
2507
expect ( pivotGrid . gridAPI . get_cell_by_index ( 0 , 0 ) . nativeElement . innerText ) . toBe ( 'Accessories/Plovdiv:undefined' ) ;
2508
2508
expect ( pivotGrid . gridAPI . get_cell_by_index ( 0 , 3 ) . nativeElement . innerText ) . toBe ( 'Accessories/London:293' ) ;
2509
2509
} ) ;
2510
+
2511
+ it ( 'should allow filtering a dimension runtime.' , ( ) => {
2512
+ const colValues = new Set ( ) ;
2513
+ colValues . add ( 'US' ) ;
2514
+ colValues . add ( 'UK' ) ;
2515
+ pivotGrid . filterDimension ( pivotGrid . pivotConfiguration . columns [ 0 ] , colValues , IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) ) ;
2516
+ expect ( pivotGrid . columns . length ) . toBe ( 6 ) ;
2517
+ expect ( pivotGrid . columns . filter ( x => x . columnGroup ) . map ( x => x . field ) ) . toEqual ( [ 'US' , 'UK' ] ) ;
2518
+ expect ( pivotGrid . filteringExpressionsTree . filteringOperands . length ) . toEqual ( 1 ) ;
2519
+
2520
+ const rowValues = new Set ( ) ;
2521
+ rowValues . add ( 'Clothing' ) ;
2522
+ pivotGrid . filterDimension ( pivotGrid . pivotConfiguration . rows [ 1 ] . childLevel , rowValues , IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) ) ;
2523
+ expect ( pivotGrid . rowList . length ) . toBe ( 4 ) ;
2524
+ const rowDimData = pivotGrid . rowList . map ( x => ( x as IgxPivotRowComponent ) . data . dimensionValues . get ( 'ProductCategory' ) )
2525
+ expect ( rowDimData ) . toEqual ( [ undefined , 'Clothing' , undefined , 'Clothing' ] ) ;
2526
+ expect ( pivotGrid . filteringExpressionsTree . filteringOperands . length ) . toEqual ( 2 ) ;
2527
+ } ) ;
2528
+
2529
+ it ( 'should update filtering on pivot configuration change.' , ( ) => {
2530
+ fixture . detectChanges ( ) ;
2531
+ expect ( pivotGrid . filteringExpressionsTree . filteringOperands . length ) . toEqual ( 0 ) ;
2532
+ const filterColumnExpTree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
2533
+ filterColumnExpTree . filteringOperands = [
2534
+ {
2535
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) ,
2536
+ fieldName : 'City' ,
2537
+ searchVal : new Set ( [ 'Ciudad de la Costa' ] )
2538
+ }
2539
+ ] ;
2540
+ const filterRowExpTree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
2541
+ filterRowExpTree . filteringOperands = [
2542
+ {
2543
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) ,
2544
+ fieldName : 'ProductCategory' ,
2545
+ searchVal : new Set ( [ 'Bikes' ] )
2546
+ }
2547
+ ] ;
2548
+ pivotGrid . pivotConfiguration = {
2549
+ columns : [
2550
+ {
2551
+ memberName : 'City' ,
2552
+ enabled : true ,
2553
+ filter : filterColumnExpTree
2554
+ }
2555
+ ] ,
2556
+ rows : [
2557
+ {
2558
+ memberName : 'ProductCategory' ,
2559
+ enabled : true ,
2560
+ filter : filterRowExpTree
2561
+ } ] ,
2562
+ values : [
2563
+ {
2564
+ member : 'UnitsSold' ,
2565
+ aggregate : {
2566
+ aggregator : IgxPivotNumericAggregate . sum ,
2567
+ key : 'SUM' ,
2568
+ label : 'Sum'
2569
+ } ,
2570
+ enabled : true
2571
+ }
2572
+ ]
2573
+ } ;
2574
+ fixture . detectChanges ( ) ;
2575
+ expect ( pivotGrid . filteringExpressionsTree . filteringOperands . length ) . toEqual ( 2 ) ;
2576
+
2577
+ expect ( pivotGrid . columns . length ) . toBe ( 1 ) ;
2578
+ expect ( pivotGrid . columns [ 0 ] . field ) . toEqual ( 'Ciudad de la Costa' ) ;
2579
+ expect ( pivotGrid . rowList . length ) . toBe ( 1 ) ;
2580
+ expect ( pivotGrid . rowList . toArray ( ) [ 0 ] . data . dimensionValues . get ( 'ProductCategory' ) ) . toBe ( 'Bikes' ) ;
2581
+ } ) ;
2510
2582
} ) ;
2511
2583
} ) ;
0 commit comments