@@ -21,7 +21,7 @@ import { GridType } from '../common/grid.interface';
21
21
import { IgxGridNavigationService } from '../grid-navigation.service' ;
22
22
import { IgxGridCRUDService } from '../common/crud.service' ;
23
23
import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
24
- import { IPivotConfiguration , IPivotKeys , PivotDimensionType } from './pivot-grid.interface' ;
24
+ import { IPivotConfiguration , IPivotDimension , IPivotKeys , PivotDimensionType } from './pivot-grid.interface' ;
25
25
import { IgxPivotHeaderRowComponent } from './pivot-header-row.component' ;
26
26
import { IgxColumnGroupComponent } from '../columns/column-group.component' ;
27
27
import { IgxColumnComponent } from '../columns/column.component' ;
@@ -491,8 +491,19 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
491
491
}
492
492
493
493
public get pivotRowWidths ( ) {
494
- const rowDimCount = this . rowDimensions . length ;
495
- return MINIMUM_COLUMN_WIDTH * rowDimCount || MINIMUM_COLUMN_WIDTH ;
494
+ return this . rowDimensions . reduce ( ( accumulator , dim ) => accumulator + this . resolveRowDimensionWidth ( dim ) , 0 ) ;
495
+ }
496
+
497
+ public resolveRowDimensionWidth ( dim : IPivotDimension ) : number {
498
+ if ( ! dim . width ) {
499
+ return MINIMUM_COLUMN_WIDTH ;
500
+ }
501
+ const isPercent = dim . width && dim . width . indexOf ( '%' ) !== - 1 ;
502
+ if ( isPercent ) {
503
+ return parseFloat ( dim . width ) / 100 * this . calcWidth ;
504
+ } else {
505
+ return parseInt ( dim . width , 10 ) ;
506
+ }
496
507
}
497
508
498
509
public get rowDimensions ( ) {
@@ -845,12 +856,13 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
845
856
ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
846
857
ref . instance . field = key ;
847
858
ref . instance . parent = parent ;
859
+ ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
848
860
ref . instance . dataType = this . pivotConfiguration . values [ 0 ] ?. dataType || this . resolveDataTypes ( data [ 0 ] [ key ] ) ;
849
861
ref . instance . formatter = this . pivotConfiguration . values [ 0 ] ?. formatter ;
850
862
ref . changeDetectorRef . detectChanges ( ) ;
851
863
columns . push ( ref . instance ) ;
852
864
if ( this . hasMultipleValues ) {
853
- const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , false ) ;
865
+ const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , false , value . dimension . width ) ;
854
866
ref . instance . children . reset ( measureChildren ) ;
855
867
columns = columns . concat ( measureChildren ) ;
856
868
}
@@ -868,6 +880,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
868
880
refSibling . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
869
881
refSibling . instance . field = key ;
870
882
refSibling . instance . parent = parent ;
883
+ ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
871
884
refSibling . instance . hidden = true ;
872
885
refSibling . instance . dataType = this . pivotConfiguration . values [ 0 ] ?. dataType || this . resolveDataTypes ( data [ 0 ] [ key ] ) ;
873
886
refSibling . instance . formatter = this . pivotConfiguration . values [ 0 ] ?. formatter ;
@@ -878,7 +891,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
878
891
ref . changeDetectorRef . detectChanges ( ) ;
879
892
columns . push ( ref . instance ) ;
880
893
if ( this . hasMultipleValues ) {
881
- const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , true ) ;
894
+ const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , true , value . dimension . width ) ;
882
895
const nestedChildren = filteredChildren . concat ( measureChildren ) ;
883
896
const allChildren = children . concat ( measureChildren ) ;
884
897
ref . instance . children . reset ( nestedChildren ) ;
@@ -893,13 +906,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
893
906
return columns ;
894
907
}
895
908
896
- protected getMeasureChildren ( colFactory , data , parent , hidden ) {
909
+ protected getMeasureChildren ( colFactory , data , parent , hidden , parentWidth ) {
897
910
const cols = [ ] ;
898
911
this . values . forEach ( val => {
899
912
const ref = colFactory . create ( this . viewRef . injector ) ;
900
913
ref . instance . header = val . displayName || val . member ;
901
914
ref . instance . field = parent . field + '-' + val . member ;
902
915
ref . instance . parent = parent ;
916
+ ref . instance . width = parentWidth || MINIMUM_COLUMN_WIDTH + 'px' ;
903
917
ref . instance . hidden = hidden ;
904
918
ref . instance . dataType = val . dataType || this . resolveDataTypes ( data [ 0 ] [ val . member ] ) ;
905
919
ref . instance . formatter = val . formatter ;
0 commit comments