@@ -10,7 +10,7 @@ export class IgxGridSummaryService {
1010 public grid : GridType ;
1111 public rootSummaryID = 'igxGridRootSummary' ;
1212 public summaryHeight = 0 ;
13- public maxSummariesLenght = 0 ;
13+ public maxSummariesLength = 0 ;
1414 public groupingExpressions = [ ] ;
1515 public retriggerRootPipe = 0 ;
1616 public deleteOperation = false ;
@@ -98,14 +98,16 @@ export class IgxGridSummaryService {
9898 }
9999 let maxSummaryLength = 0 ;
100100 this . grid . columns . filter ( ( col ) => col . hasSummary && ! col . hidden ) . forEach ( ( column ) => {
101- const getCurrentSummaryColumn = column . summaries . operate ( [ ] , [ ] , column . field ) . length ;
102- if ( getCurrentSummaryColumn ) {
103- if ( maxSummaryLength < getCurrentSummaryColumn ) {
104- maxSummaryLength = getCurrentSummaryColumn ;
105- }
101+ const getCurrentSummary = column . summaries . operate ( [ ] , [ ] , column . field ) ;
102+ const getCurrentSummaryColumn = column . disabledSummaries . length > 0
103+ ? getCurrentSummary . filter ( s => ! column . disabledSummaries . includes ( s . key ) ) . length
104+ : getCurrentSummary . length ;
105+
106+ if ( maxSummaryLength < getCurrentSummaryColumn ) {
107+ maxSummaryLength = getCurrentSummaryColumn ;
106108 }
107109 } ) ;
108- this . maxSummariesLenght = maxSummaryLength ;
110+ this . maxSummariesLength = maxSummaryLength ;
109111 this . summaryHeight = maxSummaryLength * this . grid . defaultSummaryHeight ;
110112 return this . summaryHeight ;
111113 }
@@ -123,27 +125,19 @@ export class IgxGridSummaryService {
123125
124126 this . grid . columns . filter ( col => col . hasSummary ) . forEach ( ( column ) => {
125127 if ( ! rowSummaries . get ( column . field ) ) {
126- let summaryResult = column . disabledSummaries . length
127- ? this . getCachedSummary ( column . field , column . disabledSummaries ) || null
128- : null ;
128+ let summaryResult = column . summaries . operate (
129+ data . map ( r => resolveNestedPath ( r , column . field ) ) ,
130+ data ,
131+ column . field ,
132+ groupRecord ,
133+ this . grid . locale ,
134+ column . pipeArgs
135+ ) ;
129136
130- if ( ! summaryResult ) {
131- summaryResult = column . summaries . operate (
132- data . map ( r => resolveNestedPath ( r , column . field ) ) ,
133- data ,
134- column . field ,
135- groupRecord ,
136- this . grid . locale ,
137- column . pipeArgs
138- ) ;
137+ summaryResult = column . disabledSummaries . length > 0
138+ ? summaryResult . filter ( s => ! column . disabledSummaries . includes ( s . key ) )
139+ : summaryResult ;
139140
140- if ( column . disabledSummaries . length ) {
141- summaryResult = summaryResult . filter (
142- result => ! column . disabledSummaries . includes ( result . key )
143- ) ;
144- this . cacheSummary ( column . field , summaryResult , column . disabledSummaries ) ;
145- }
146- }
147141 rowSummaries . set ( column . field , summaryResult ) ;
148142 }
149143 } ) ;
@@ -266,17 +260,4 @@ export class IgxGridSummaryService {
266260 } ) ;
267261 }
268262 }
269-
270- private cacheSummary ( field : string , summaryResult : IgxSummaryResult [ ] , disabledSummaries : string [ ] = [ ] ) {
271- if ( ! this . summaryCacheMap . has ( field ) ) {
272- this . summaryCacheMap . set ( field , new Map < string , IgxSummaryResult [ ] > ( ) ) ;
273- }
274- const cacheKey = JSON . stringify ( disabledSummaries ) ;
275- this . summaryCacheMap . get ( field ) . set ( cacheKey , summaryResult ) ;
276- }
277-
278- private getCachedSummary ( field : string , disabledSummaries : string [ ] = [ ] ) : IgxSummaryResult [ ] | undefined {
279- const cacheKey = JSON . stringify ( disabledSummaries ) ;
280- return this . summaryCacheMap . get ( field ) ?. get ( cacheKey ) ;
281- }
282263}
0 commit comments