grouping/aggregation filter applying to entire aggregation string
This issue seen in the latest unstable build.
The aggregated values in a grouping header row have any cell filters applied after the aggregation string is built (e.g. filter runs against "avg: data" instead of against data), which causes many filters to fail.
See this issue in http://plnkr.co/edit/VBIbnVYcY4ra825647Vy
That's what the option groupingSuppressAggregationText is for, it's documented on http://ui-grid.info/docs/#/tutorial/209_grouping
So it is... I scanned right over that part of the documentation.
I looked to see if it was an enhancement/fix I could contribute without much risk to the rest of ui-grid, but looking through the code it looks like it would require a number of changes all over in core pieces since grouping rows use the same row and cell templates as data rows.
As a temporary workaround for my own purposes I added the following to my cell template:
{{row.groupHeader && col.grouping.aggregation ? (col.grouping.aggregation + ': ') : ''}}
Not ideal, from a performance perspective, since the same cell template is used for every data row. But it's functional to get the aggregation text + filtered data.
Based on your addition to the Future milestone, I guess you're in favor of leaving this open as a possible future enhancement/bugfix? Since it's documented that seems very reasonable. Thanks for the quick response.
Yeah, although I have no idea how to actually change it, since the filters get applied via an angular binding. I could maybe write a filter that applies the totals/aggregations, and add that filter to the end of the filters, but it's getting a little too tricky I think.
In my code, I just unstring it in the filter. Most commonly I'm doing this on a reference data lookup (changing 1 => active, 2=> inactive or similar). I have a generic routine that makes filters for my ref data:
.factory('SystemRefDataService', function( ){
var systemRefDataService = {
genericMap: function( constant, constantName ) {
return function (input) {
var result;
var match;
if(!input) {
return '';
} else if (result = constant[input]) {
return result;
} else if ( ( match = input.match(/(\d+)( \(\d+\))/) ) && ( result = constant[match[1]] ) ) {
return result + match[2];
} else {
if(!$rootScope[constantName + 'Error']) {
LoggingService.logError('42001: ' + constantName + ' not recognised', 'SYSTEM_REF_DATA', {input: input});
$rootScope[constantName + 'Error'] = true;
}
return 'MSG_base_42001_system_ref_data_not_recognised';
}
};
}
};
return systemRefDataService;
})
I hold most of my refData in constants in the format:
.factory( 'ProjectStatusesConstant', function() {
return {
1: 'VALUE_project_project_status_active',
2: 'VALUE_project_project_status_inactive'
};
})
So I can define a filter by:
.filter('mapProjectStatus', function( ProjectStatusesConstant, SystemRefDataService ) {
return SystemRefDataService.genericMap( ProjectStatusesConstant, 'project_statuses');
})
I think this may be addressed in the newest version of grouping (which has significant breaking changes).
You can now define a customTreeAggregationFinalizerFn that doesn't concatenate the data, and then concatenate the data in a cellTemplate instead (the label and the value are both now separately available for you to do things with if you wish).