@@ -37,7 +37,7 @@ import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives
3737import { ColumnType , GridType , IGX_GRID_BASE , IgxColumnTemplateContext , RowType } from '../common/grid.interface' ;
3838import { IgxGridCRUDService } from '../common/crud.service' ;
3939import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
40- import { DEFAULT_PIVOT_KEYS , IDimensionsChange , IgxPivotGridValueTemplateContext , IPivotConfiguration , IPivotConfigurationChangedEventArgs , IPivotDimension , IPivotValue , IValuesChange , PivotDimensionType , IPivotUISettings } from './pivot-grid.interface' ;
40+ import { DEFAULT_PIVOT_KEYS , IDimensionsChange , IgxPivotGridValueTemplateContext , IPivotConfiguration , IPivotConfigurationChangedEventArgs , IPivotDimension , IPivotValue , IValuesChange , PivotDimensionType , IPivotUISettings , IPivotGridRecord , IPivotGridHorizontalGroup } from './pivot-grid.interface' ;
4141import { IgxPivotHeaderRowComponent } from './pivot-header-row.component' ;
4242import { IgxColumnGroupComponent } from '../columns/column-group.component' ;
4343import { IgxColumnComponent } from '../columns/column.component' ;
@@ -73,7 +73,7 @@ import { DataUtil } from '../../data-operations/data-util';
7373import { IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree' ;
7474import { IgxGridTransaction } from '../common/types' ;
7575import { GridBaseAPIService } from '../api.service' ;
76- import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive' ;
76+ import { IForOfDataChangingEventArgs , IgxGridForOfDirective } from '../../directives/for-of/for_of.directive' ;
7777import { IgxPivotRowDimensionContentComponent } from './pivot-row-dimension-content.component' ;
7878import { IgxPivotGridColumnResizerComponent } from '../resizing/pivot-grid/pivot-resizer.component' ;
7979import { IgxActionStripToken } from '../../action-strip/token' ;
@@ -83,7 +83,7 @@ import { IFilteringStrategy } from '../../data-operations/filtering-strategy';
8383import { IgxPivotRowDimensionHeaderTemplateDirective , IgxPivotValueChipTemplateDirective } from './pivot-grid.directives' ;
8484import { IFilteringOperation } from '../../data-operations/filtering-condition' ;
8585import { IgxGridValidationService } from '../grid/grid-validation.service' ;
86- import { IgxPivotRowPipe , IgxPivotRowExpansionPipe , IgxPivotAutoTransform , IgxPivotColumnPipe , IgxPivotGridFilterPipe , IgxPivotGridSortingPipe , IgxPivotGridColumnSortingPipe , IgxPivotCellMergingPipe } from './pivot-grid.pipes' ;
86+ import { IgxPivotRowPipe , IgxPivotRowExpansionPipe , IgxPivotAutoTransform , IgxPivotColumnPipe , IgxPivotGridFilterPipe , IgxPivotGridSortingPipe , IgxPivotGridColumnSortingPipe , IgxPivotCellMergingPipe , IgxPivotGridHorizontalRowGrouping , IgxPivotGridHorizontalRowCellMerging } from './pivot-grid.pipes' ;
8787import { IgxGridRowClassesPipe , IgxGridRowStylesPipe } from '../common/pipes' ;
8888import { IgxExcelStyleSearchComponent } from '../filtering/excel-style/excel-style-search.component' ;
8989import { IgxIconComponent } from '../../icon/icon.component' ;
@@ -174,7 +174,9 @@ const MINIMUM_COLUMN_WIDTH_SUPER_COMPACT = 104;
174174 IgxPivotGridFilterPipe ,
175175 IgxPivotGridSortingPipe ,
176176 IgxPivotGridColumnSortingPipe ,
177- IgxPivotCellMergingPipe
177+ IgxPivotCellMergingPipe ,
178+ IgxPivotGridHorizontalRowGrouping ,
179+ IgxPivotGridHorizontalRowCellMerging
178180 ] ,
179181 schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
180182} )
@@ -306,6 +308,9 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
306308 @Input ( )
307309 public rowDimensionHeaderTemplate : TemplateRef < IgxColumnTemplateContext > ;
308310
311+ @Input ( )
312+ public horizontalRowDimensions = false ;
313+
309314 @Input ( )
310315 /**
311316 * Gets/Sets the pivot configuration with all related dimensions and values.
@@ -608,7 +613,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
608613 /** @hidden @internal */
609614 public columnGroupStates = new Map < string , boolean > ( ) ;
610615 /** @hidden @internal */
611- public dimensionDataColumns ;
616+ public dimensionDataColumns : any [ ] ;
612617 /** @hidden @internal */
613618 public get pivotKeys ( ) {
614619 return this . pivotConfiguration . pivotKeys || DEFAULT_PIVOT_KEYS ;
@@ -650,6 +655,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
650655 private _superCompactMode = false ;
651656 private _pivotUI : IPivotUISettings = { showConfiguration : true , showRowHeaders : false } ;
652657 private _sortableColumns = true ;
658+ private _visibleRowDimensions : IPivotDimension [ ] = [ ] ;
659+ private _flattenedRowDimensions : IPivotDimension [ ] = [ ] ;
653660
654661 /**
655662 * Gets/Sets the default expand state for all rows.
@@ -1062,6 +1069,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10621069 return ( config . rows || [ ] ) . concat ( ( config . columns || [ ] ) ) . concat ( config . filters || [ ] ) . filter ( x => x !== null && x !== undefined ) ;
10631070 }
10641071
1072+ public get allVisibleDimensions ( ) {
1073+ const config = this . _pivotConfiguration ;
1074+ const uniqueVisibleRowDims = this . visibleRowDimensions . filter ( dim => ! config . rows . find ( configRow => configRow . memberName === dim . memberName ) ) ;
1075+ const rows = ( config . rows || [ ] ) . concat ( ...uniqueVisibleRowDims ) ;
1076+ if ( ! config ) return [ ] ;
1077+ return rows . concat ( ( config . columns || [ ] ) ) . concat ( config . filters || [ ] ) . filter ( x => x !== null && x !== undefined ) ;
1078+ }
1079+
10651080 /** @hidden @internal */
10661081 public createFilterESF ( dropdown : any , column : ColumnType , options : OverlaySettings , shouldReatach : boolean ) {
10671082 options . outlet = this . outlet ;
@@ -1151,7 +1166,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11511166 * @hidden @internal
11521167 */
11531168 public get pivotRowWidths ( ) {
1154- return this . rowDimensions . length ? this . rowDimensions . reduce ( ( accumulator , dim ) => accumulator + this . rowDimensionWidthToPixels ( dim ) , 0 ) :
1169+ return this . visibleRowDimensions . length ? this . visibleRowDimensions . reduce ( ( accumulator , dim ) => accumulator + this . rowDimensionWidthToPixels ( dim ) , 0 ) :
11551170 this . rowDimensionWidthToPixels ( this . emptyRowDimension ) ;
11561171 }
11571172
@@ -1189,6 +1204,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11891204 }
11901205 }
11911206
1207+ public rowDimensionWidthCombined ( dims : IPivotDimension [ ] ) {
1208+ let resWidth = 0 ;
1209+ for ( const dim of dims ) {
1210+ resWidth += this . rowDimensionWidthToPixels ( dim ) ;
1211+ }
1212+ return resWidth ;
1213+ }
1214+
11921215 /**
11931216 * @hidden @internal
11941217 */
@@ -1219,6 +1242,22 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
12191242 return this . pivotConfiguration . rows ?. filter ( x => x . enabled ) || [ ] ;
12201243 }
12211244
1245+ /** @hidden @internal */
1246+ public set visibleRowDimensions ( value : IPivotDimension [ ] ) {
1247+ this . _visibleRowDimensions = value ;
1248+ }
1249+
1250+ public get visibleRowDimensions ( ) {
1251+ return this . _visibleRowDimensions || this . rowDimensions ;
1252+ }
1253+
1254+ public get flattenedRowDimensions ( ) {
1255+ if ( this . rowDimensions . length > 0 && this . _flattenedRowDimensions . length === 0 ) {
1256+ this . _flattenedRowDimensions = this . flattenRowDimensions ( ) ;
1257+ }
1258+ return this . _flattenedRowDimensions ;
1259+ }
1260+
12221261 /** @hidden @internal */
12231262 public get columnDimensions ( ) {
12241263 return this . pivotConfiguration . columns ?. filter ( x => x . enabled ) || [ ] ;
@@ -1538,6 +1577,17 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
15381577 super . setupColumns ( ) ;
15391578 }
15401579
1580+ /**
1581+ * @hidden @internal
1582+ */
1583+ public override dataRebinding ( event : IForOfDataChangingEventArgs ) {
1584+ super . dataRebinding ( event ) ;
1585+
1586+ if ( this . horizontalRowDimensions ) {
1587+ this . setupColumns ( ) ;
1588+ }
1589+ }
1590+
15411591 /**
15421592 * Auto-sizes row dimension cells.
15431593 *
@@ -2026,6 +2076,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
20262076 }
20272077 columns = this . generateColumnHierarchy ( fieldsMap , sortedData ) ;
20282078 this . _autoGeneratedCols = columns ;
2079+ this . _flattenedRowDimensions = this . flattenRowDimensions ( ) ;
20292080 // reset expansion states if any are stored.
20302081 this . columnGroupStates . forEach ( ( value , key ) => {
20312082 if ( value ) {
@@ -2046,9 +2097,21 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
20462097 }
20472098
20482099
2100+ protected flattenRowDimensions ( ) : IPivotDimension [ ] {
2101+ const res = [ ] ;
2102+ for ( let i = 0 ; i < this . rowDimensions . length ; i ++ ) {
2103+ let curLevelDim = this . rowDimensions [ i ] ;
2104+ do {
2105+ res . push ( curLevelDim ) ;
2106+ curLevelDim = curLevelDim . childLevel ;
2107+ } while ( curLevelDim ) ;
2108+ } ;
2109+ return res ;
2110+ }
2111+
20492112 protected generateDimensionColumns ( ) : IgxColumnComponent [ ] {
20502113 const columns = [ ] ;
2051- this . allDimensions . forEach ( ( dim ) => {
2114+ this . allVisibleDimensions . forEach ( ( dim ) => {
20522115 const ref = createComponent ( IgxColumnComponent , { environmentInjector : this . envInjector , elementInjector : this . injector } ) ;
20532116 ref . instance . field = dim . memberName ;
20542117 ref . instance . header = dim . displayName || dim . memberName ;
@@ -2341,12 +2404,33 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
23412404 }
23422405
23432406 protected rowDimensionByName ( memberName : string ) {
2344- return this . rowDimensions . find ( ( rowDim ) => rowDim . memberName === memberName ) ;
2407+ return this . visibleRowDimensions . find ( ( rowDim ) => rowDim . memberName === memberName ) ;
23452408 }
23462409
23472410 protected calculateResizerTop ( ) {
23482411 return this . pivotUI . showRowHeaders ?
23492412 ( this . theadRow . pivotFilterContainer ?. nativeElement . offsetHeight || 0 ) + ( this . theadRow . pivotRowContainer ?. nativeElement . offsetHeight || 0 ) :
23502413 this . theadRow . nativeElement . offsetHeight ;
23512414 }
2415+
2416+ protected getRowMRLTemplate ( forRows : boolean , rows : IPivotGridRecord [ ] ) {
2417+ if ( forRows ) {
2418+ return `repeat(${ rows . length } ,1fr)` ;
2419+ } else if ( this . visibleRowDimensions && this . dimensionDataColumns ) {
2420+ const res = [ ] ;
2421+ this . visibleRowDimensions . forEach ( dim => {
2422+ const targetCol = this . dimensionDataColumns . find ( col => col . field === dim . memberName ) ;
2423+ res . push ( targetCol . calcWidth ) ;
2424+ } ) ;
2425+ return res . join ( ' ' ) ;
2426+ }
2427+ }
2428+
2429+ protected calcRowIndex ( groupedData : IPivotGridRecord [ ] [ ] , rowIndex : number , cell : IPivotGridHorizontalGroup ) {
2430+ let prevRows = 0 ;
2431+ for ( let i = 0 ; i < rowIndex ; i ++ ) {
2432+ prevRows += groupedData [ i ] . length ;
2433+ }
2434+ return prevRows + ( cell . rowStart - 1 ) ;
2435+ }
23522436}
0 commit comments