Skip to content

Commit 9fbb1b8

Browse files
author
ndudenhoeffer
committed
feat(grouping): Add option groupingNullLabel, to group null and undefined values together.
Fixes #3271
1 parent efd3798 commit 9fbb1b8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/features/grouping/js/grouping.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,15 @@
449449
* <br/>Defaults to true
450450
*/
451451
gridOptions.groupingShowCounts = gridOptions.groupingShowCounts !== false;
452+
453+
/**
454+
* @ngdoc object
455+
* @name groupingNullLabel
456+
* @propertyOf ui.grid.grouping.api:GridOptions
457+
* @description The string to use for the grouping header row label on rows which contain a null or undefined value in the grouped column.
458+
* <br/>Defaults to "Null"
459+
*/
460+
gridOptions.groupingNullLabel = gridOptions.groupingNullLabel || 'Null';
452461
},
453462

454463

@@ -1140,7 +1149,7 @@
11401149
var updateProcessingState = function( groupFieldState, stateIndex ) {
11411150
var fieldValue = grid.getCellValue(row, groupFieldState.col);
11421151
if ( typeof(fieldValue) === 'undefined' || fieldValue === null ){
1143-
return;
1152+
fieldValue = grid.options.groupingNullLabel;
11441153
}
11451154

11461155
if ( !row.visible ){
@@ -1287,6 +1296,9 @@
12871296

12881297
// TODO: can't just use entity like this, have to use get cell value, need col for that
12891298
var newValue = grid.getCellValue(renderableRows[rowIndex], col);
1299+
if ( typeof(newValue) === 'undefined' || newValue === null ) {
1300+
newValue = grid.options.groupingNullLabel;
1301+
}
12901302
headerRow.entity[fieldName] = newValue;
12911303
headerRow.groupLevel = stateIndex;
12921304
headerRow.groupHeader = true;

0 commit comments

Comments
 (0)