Skip to content

Commit 6a2b503

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents bef33a9 + db54977 commit 6a2b503

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/features/grouping/js/grouping.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,6 @@
889889
// Broken out as shouldn't create functions in a loop.
890890
var updateProcessingState = function( groupFieldState, stateIndex ) {
891891
var fieldValue = grid.getCellValue(row, groupFieldState.col);
892-
if ( typeof(fieldValue) === 'undefined' || fieldValue === null ){
893-
fieldValue = grid.options.groupingNullLabel;
894-
}
895892

896893
// look for change of value - and insert a header
897894
if ( !groupFieldState.initialised || rowSorter.getSortFn(grid, groupFieldState.col, renderableRows)(fieldValue, groupFieldState.currentValue) !== 0 ){
@@ -1007,8 +1004,9 @@
10071004
var col = processingState[stateIndex].col;
10081005

10091006
var newValue = grid.getCellValue(renderableRows[rowIndex], col);
1007+
var newDisplayValue = newValue;
10101008
if ( typeof(newValue) === 'undefined' || newValue === null ) {
1011-
newValue = grid.options.groupingNullLabel;
1009+
newDisplayValue = grid.options.groupingNullLabel;
10121010
}
10131011

10141012
var cacheItem = grid.grouping.oldGroupingHeaderCache;
@@ -1027,7 +1025,7 @@
10271025
gridClassFactory.rowTemplateAssigner.call(grid, headerRow);
10281026
}
10291027

1030-
headerRow.entity['$$' + processingState[stateIndex].col.uid] = { groupVal: newValue };
1028+
headerRow.entity['$$' + processingState[stateIndex].col.uid] = { groupVal: newDisplayValue };
10311029
headerRow.treeLevel = stateIndex;
10321030
headerRow.groupHeader = true;
10331031
headerRow.internalRow = true;

src/features/grouping/test/grouping.spec.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
2828
{field: 'col0', enableGrouping: true},
2929
{field: 'col1', enableGrouping: true},
3030
{field: 'col2', enableGrouping: true},
31-
{field: 'col3', enableGrouping: true}
31+
{field: 'col3', enableGrouping: true},
32+
{field: 'col4', enableGrouping: true, type: 'date'}
3233
];
3334

3435
uiGridGroupingService.initializeGrid(grid, $scope);
3536
var data = [];
3637
for (var i = 0; i < 10; i++) {
37-
data.push({col0: 'a_' + Math.floor(i/4), col1: 'b_' + Math.floor(i/2), col2: 'c_' + i, col3: 'd_' + i});
38+
39+
data.push({
40+
col0: 'a_' + Math.floor(i/4),
41+
col1: 'b_' + Math.floor(i/2),
42+
col2: 'c_' + i,
43+
col3: 'd_' + i,
44+
col4: i > 5 ? new Date(2015, 6, 1) : null
45+
});
3846
}
3947
grid.options.data = data;
4048

@@ -83,6 +91,15 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
8391
var groupedRows = uiGridGroupingService.groupRows.call( grid, grid.rows.slice(0) );
8492
expect( groupedRows.length ).toEqual( 18, 'all rows are present, including the added group headers' );
8593
});
94+
95+
it( 'group by col4 (type date with nulls)', function() {
96+
spyOn(gridClassFactory, 'rowTemplateAssigner').andCallFake( function() {});
97+
grid.columns[4].grouping = { groupPriority: 1 };
98+
99+
uiGridGroupingService.tidyPriorities(grid);
100+
var groupedRows = uiGridGroupingService.groupRows.call( grid, grid.rows.slice(0) );
101+
expect( groupedRows.length ).toEqual( 12, 'all rows are present, including two group header rows' );
102+
});
86103
});
87104

88105
describe('initialiseProcessingState', function() {

0 commit comments

Comments
 (0)