@@ -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 ;
@@ -1028,6 +1029,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10281029 summaryService : IgxGridSummaryService ,
10291030 @Inject ( LOCALE_ID ) localeId : string ,
10301031 platform : PlatformUtil ,
1032+ private pivotStateService : IgxPivotGridStateService ,
10311033 @Optional ( ) @Inject ( IgxGridTransaction ) _diTransactions ?: TransactionService < Transaction , State >
10321034 ) {
10331035 super (
@@ -2280,11 +2282,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
22802282 if ( fields . size === 0 ) {
22812283 this . values . forEach ( ( value ) => {
22822284 const ref = createComponent ( IgxColumnComponent , { environmentInjector : this . envInjector , elementInjector : this . injector } ) ;
2285+ let columnDataType = value . dataType || this . resolveDataTypes ( data . length ? data [ 0 ] [ value . member ] : null ) ;
2286+
2287+ if ( value . aggregate ?. key ?. toLowerCase ( ) === 'count' && columnDataType === GridColumnDataType . Currency ) {
2288+ this . pivotStateService . addCurrencyColumn ( value . member ) ;
2289+ columnDataType = GridColumnDataType . Number ;
2290+ }
2291+
22832292 ref . instance . header = value . displayName ;
22842293 ref . instance . field = value . member ;
22852294 ref . instance . parent = parent ;
22862295 ref . instance . sortable = true ;
2287- ref . instance . dataType = value . dataType || this . resolveDataTypes ( data . length ? data [ 0 ] [ value . member ] : null ) ;
2296+ ref . instance . dataType = columnDataType ;
22882297 ref . instance . formatter = value . formatter ;
22892298 columns . push ( ref . instance ) ;
22902299 } ) ;
@@ -2298,9 +2307,35 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
22982307 }
22992308 if ( shouldGenerate && ( value . children == null || value . children . length === 0 || value . children . size === 0 ) ) {
23002309 const col = this . createColumnForDimension ( value , data , parent , this . hasMultipleValues ) ;
2310+
2311+ this . values . forEach ( ( aggregatorValue ) => {
2312+ if ( col . dataType === GridColumnDataType . Currency && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) === 'count' ) {
2313+ col . dataType = GridColumnDataType . Number ;
2314+ this . pivotStateService . addCurrencyColumn ( aggregatorValue . member ) ;
2315+ } else if ( this . pivotStateService . isCurrencyColumn ( aggregatorValue . member ) && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) !== 'count' ) {
2316+ col . dataType = GridColumnDataType . Currency ;
2317+ this . pivotStateService . removeCurrencyColumn ( aggregatorValue . member ) ;
2318+ }
2319+ } )
2320+
23012321 columns . push ( col ) ;
23022322 if ( this . hasMultipleValues ) {
23032323 const measureChildren = this . getMeasureChildren ( data , col , false , value . dimension . width ) ;
2324+
2325+ measureChildren . forEach ( ( child ) => {
2326+ this . values . forEach ( ( aggregatorValue ) => {
2327+ if ( child . field . includes ( aggregatorValue . member ) ) {
2328+ if ( child . dataType === GridColumnDataType . Currency && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) === 'count' ) {
2329+ child . dataType = GridColumnDataType . Number ;
2330+ this . pivotStateService . addCurrencyColumn ( aggregatorValue . member ) ;
2331+ } else if ( this . pivotStateService . isCurrencyColumn ( aggregatorValue . member ) && aggregatorValue . aggregate ?. key ?. toLowerCase ( ) !== 'count' ) {
2332+ child . dataType = GridColumnDataType . Currency ;
2333+ this . pivotStateService . removeCurrencyColumn ( aggregatorValue . member ) ;
2334+ }
2335+ }
2336+ } )
2337+ } )
2338+
23042339 col . children . reset ( measureChildren ) ;
23052340 columns = columns . concat ( measureChildren ) ;
23062341 }
0 commit comments