@@ -71,7 +71,7 @@ import { IgxPivotColumnResizingService } from '../resizing/pivot-grid/pivot-resi
7171import { IgxFlatTransactionFactory , IgxOverlayService , State , Transaction , TransactionService } from '../../services/public_api' ;
7272import { cloneArray , PlatformUtil , resizeObservable } from '../../core/utils' ;
7373import { IgxPivotFilteringService } from './pivot-filtering.service' ;
74- import { DataUtil } from '../../data-operations/data-util' ;
74+ import { DataUtil , GridColumnDataType } from '../../data-operations/data-util' ;
7575import { IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree' ;
7676import { IgxGridTransaction } from '../common/types' ;
7777import { GridBaseAPIService } from '../api.service' ;
@@ -102,6 +102,7 @@ import { IgxTextHighlightService } from '../../directives/text-highlight/text-hi
102102import { IgxPivotRowHeaderGroupComponent } from './pivot-row-header-group.component' ;
103103import { IgxPivotDateDimension } from './pivot-grid-dimensions' ;
104104import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component' ;
105+ import { IgxPivotGridStateService } from './pivot-grid-state.service' ;
105106
106107let NEXT_ID = 0 ;
107108const MINIMUM_COLUMN_WIDTH = 200 ;
@@ -1031,6 +1032,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10311032 summaryService : IgxGridSummaryService ,
10321033 @Inject ( LOCALE_ID ) localeId : string ,
10331034 platform : PlatformUtil ,
1035+ private pivotStateService : IgxPivotGridStateService ,
10341036 @Optional ( ) @Inject ( IgxGridTransaction ) _diTransactions ?: TransactionService < Transaction , State >
10351037 ) {
10361038 super (
@@ -2281,11 +2283,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
22812283 if ( fields . size === 0 ) {
22822284 this . values . forEach ( ( value ) => {
22832285 const ref = createComponent ( IgxColumnComponent , { environmentInjector : this . envInjector , elementInjector : this . injector } ) ;
2286+ let columnDataType = value . dataType || this . resolveDataTypes ( data . length ? data [ 0 ] [ value . member ] : null ) ;
2287+
2288+ if ( value . aggregate ?. key ?. toLowerCase ( ) === 'count' && columnDataType === GridColumnDataType . Currency ) {
2289+ this . pivotStateService . addCurrencyColumn ( value . member ) ;
2290+ columnDataType = GridColumnDataType . Number ;
2291+ }
2292+
22842293 ref . instance . header = value . displayName ;
22852294 ref . instance . field = value . member ;
22862295 ref . instance . parent = parent ;
22872296 ref . instance . sortable = true ;
2288- ref . instance . dataType = value . dataType || this . resolveDataTypes ( data . length ? data [ 0 ] [ value . member ] : null ) ;
2297+ ref . instance . dataType = columnDataType ;
22892298 ref . instance . formatter = value . formatter ;
22902299 columns . push ( ref . instance ) ;
22912300 } ) ;
@@ -2299,9 +2308,35 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
22992308 }
23002309 if ( shouldGenerate && ( value . children == null || value . children . length === 0 || value . children . size === 0 ) ) {
23012310 const col = this . createColumnForDimension ( value , data , parent , this . hasMultipleValues ) ;
2311+
2312+ this . values . forEach ( ( aggregatorValue ) => {
2313+ if ( col . dataType === GridColumnDataType . Currency && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) === 'count' ) {
2314+ col . dataType = GridColumnDataType . Number ;
2315+ this . pivotStateService . addCurrencyColumn ( aggregatorValue . member ) ;
2316+ } else if ( this . pivotStateService . isCurrencyColumn ( aggregatorValue . member ) && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) !== 'count' ) {
2317+ col . dataType = GridColumnDataType . Currency ;
2318+ this . pivotStateService . removeCurrencyColumn ( aggregatorValue . member ) ;
2319+ }
2320+ } )
2321+
23022322 columns . push ( col ) ;
23032323 if ( this . hasMultipleValues ) {
23042324 const measureChildren = this . getMeasureChildren ( data , col , false , value . dimension . width ) ;
2325+
2326+ measureChildren . forEach ( ( child ) => {
2327+ this . values . forEach ( ( aggregatorValue ) => {
2328+ if ( child . field . includes ( aggregatorValue . member ) ) {
2329+ if ( child . dataType === GridColumnDataType . Currency && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) === 'count' ) {
2330+ child . dataType = GridColumnDataType . Number ;
2331+ this . pivotStateService . addCurrencyColumn ( aggregatorValue . member ) ;
2332+ } else if ( this . pivotStateService . isCurrencyColumn ( aggregatorValue . member ) && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) !== 'count' ) {
2333+ child . dataType = GridColumnDataType . Currency ;
2334+ this . pivotStateService . removeCurrencyColumn ( aggregatorValue . member ) ;
2335+ }
2336+ }
2337+ } )
2338+ } )
2339+
23052340 col . children . reset ( measureChildren ) ;
23062341 columns = columns . concat ( measureChildren ) ;
23072342 }
0 commit comments