Skip to content

Commit d632063

Browse files
author
Akshit Singhal
committed
fix(grouping): When 'field' in columnDef is referred to some javascript object than a primitive type.
Grouping fails when 'field' in columnDef is referred to some javascript object than a primitive type. Resolves issue [4493](#4493)
1 parent fe00489 commit d632063

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/features/grouping/js/grouping.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1050,16 +1050,24 @@
10501050
newDisplayValue = grid.options.groupingNullLabel;
10511051
}
10521052

1053+
var getKeyAsValueForCacheMap = function(key) {
1054+
if (angular.isObject(key)) {
1055+
return JSON.stringify(key);
1056+
} else {
1057+
return key;
1058+
}
1059+
};
1060+
10531061
var cacheItem = grid.grouping.oldGroupingHeaderCache;
10541062
for ( var i = 0; i < stateIndex; i++ ){
1055-
if ( cacheItem && cacheItem[processingState[i].currentValue] ){
1056-
cacheItem = cacheItem[processingState[i].currentValue].children;
1063+
if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)] ){
1064+
cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;
10571065
}
10581066
}
10591067

10601068
var headerRow;
1061-
if ( cacheItem && cacheItem[newValue]){
1062-
headerRow = cacheItem[newValue].row;
1069+
if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(newValue)]){
1070+
headerRow = cacheItem[getKeyAsValueForCacheMap(newValue)].row;
10631071
headerRow.entity = {};
10641072
} else {
10651073
headerRow = new GridRow( {}, null, grid );
@@ -1086,9 +1094,9 @@
10861094
// add our new header row to the cache
10871095
cacheItem = grid.grouping.groupingHeaderCache;
10881096
for ( i = 0; i < stateIndex; i++ ){
1089-
cacheItem = cacheItem[processingState[i].currentValue].children;
1097+
cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;
10901098
}
1091-
cacheItem[newValue] = { row: headerRow, children: {} };
1099+
cacheItem[getKeyAsValueForCacheMap(newValue)] = { row: headerRow, children: {} };
10921100
},
10931101

10941102

0 commit comments

Comments
 (0)