Skip to content

Commit

Permalink
fix(grouping): When 'field' in columnDef is referred to some javascri…
Browse files Browse the repository at this point in the history
…pt 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)
  • Loading branch information
Akshit Singhal committed Oct 8, 2015
1 parent fe00489 commit d632063
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/features/grouping/js/grouping.js
Expand Up @@ -1050,16 +1050,24 @@
newDisplayValue = grid.options.groupingNullLabel;
}

var getKeyAsValueForCacheMap = function(key) {
if (angular.isObject(key)) {
return JSON.stringify(key);
} else {
return key;
}
};

var cacheItem = grid.grouping.oldGroupingHeaderCache;
for ( var i = 0; i < stateIndex; i++ ){
if ( cacheItem && cacheItem[processingState[i].currentValue] ){
cacheItem = cacheItem[processingState[i].currentValue].children;
if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)] ){
cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;
}
}

var headerRow;
if ( cacheItem && cacheItem[newValue]){
headerRow = cacheItem[newValue].row;
if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(newValue)]){
headerRow = cacheItem[getKeyAsValueForCacheMap(newValue)].row;
headerRow.entity = {};
} else {
headerRow = new GridRow( {}, null, grid );
Expand All @@ -1086,9 +1094,9 @@
// add our new header row to the cache
cacheItem = grid.grouping.groupingHeaderCache;
for ( i = 0; i < stateIndex; i++ ){
cacheItem = cacheItem[processingState[i].currentValue].children;
cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;
}
cacheItem[newValue] = { row: headerRow, children: {} };
cacheItem[getKeyAsValueForCacheMap(newValue)] = { row: headerRow, children: {} };
},


Expand Down

0 comments on commit d632063

Please sign in to comment.