@@ -76,7 +76,7 @@ export class IgxSorting implements IGridSortingStrategy {
7676 grid : GridType = null ,
7777 groupsRecords : any [ ] = [ ] ,
7878 fullResult : IGroupByResult = { data : [ ] , metadata : [ ] }
79- ) : any [ ] {
79+ ) : IGroupByResult {
8080 const expressions = state . expressions ;
8181 const expansion = state . expansion ;
8282 let i = 0 ;
@@ -117,23 +117,24 @@ export class IgxSorting implements IGridSortingStrategy {
117117 fullResult . metadata . push ( null ) ;
118118 if ( level < expressions . length - 1 ) {
119119 recursiveResult = this . groupDataRecursive ( group , state , level + 1 , groupRow ,
120- expanded ? metadata : [ ] , grid , groupsRecords , fullResult ) ;
120+ [ ] , grid , groupsRecords , fullResult ) ;
121121 if ( expanded ) {
122- result = result . concat ( recursiveResult ) ;
122+ result = result . concat ( recursiveResult . data ) ;
123+ metadata = metadata . concat ( recursiveResult . metadata ) ;
123124 }
124125 } else {
125126 for ( const groupItem of group ) {
126127 fullResult . metadata . push ( groupRow ) ;
127128 fullResult . data . push ( groupItem ) ;
128129 }
129130 if ( expanded ) {
130- metadata . push ( ... fullResult . metadata . slice ( fullResult . metadata . length - group . length ) ) ;
131- result . push ( ... fullResult . data . slice ( fullResult . data . length - group . length ) ) ;
131+ metadata = metadata . concat ( fullResult . metadata . slice ( fullResult . metadata . length - group . length ) ) ;
132+ result = result . concat ( fullResult . data . slice ( fullResult . data . length - group . length ) ) ;
132133 }
133134 }
134135 i += group . length ;
135136 }
136- return result ;
137+ return { data : result , metadata } ;
137138 }
138139
139140 /**
@@ -264,8 +265,8 @@ export class IgxGrouping extends IgxSorting implements IGridGroupingStrategy {
264265 const grouping = this . groupDataRecursive ( data , state , 0 , null , metadata , grid , groupsRecords , fullResult ) ;
265266 grid ?. groupingPerformedSubject . next ( ) ;
266267 return {
267- data : grouping ,
268- metadata
268+ data : grouping . data ,
269+ metadata : grouping . metadata
269270 } ;
270271 }
271272}
0 commit comments