feat(ngrid): support for Row Grouping (Aggregation) #60
Replies: 3 comments
-
As far as I know at the moment aggregation is possible in a summary row created using same column definitions as main rows to match grid columns. If only some of the columns need to be aggregated, column placeholders need to be used otherwise 24 (first) or 14 (subsequent) cell margins will make the footer out of sync with the grid: |
Beta Was this translation helpful? Give feedback.
-
Any ETA on when work will begin on this feature? I'm also willing to help implement it but I don't know where to start from |
Beta Was this translation helpful? Give feedback.
-
For those who are still waiting, one way to add a summary row is to create a footer def like this <div *pblNgridFooterCellDef="'*'; col as col; grid as grid">{{ grid._dataSource._source | sum : col.prop }}</div> As for the pipe, here's what it looks like: @Pipe({
name: "sum",
})
export class SumPipe implements PipeTransform {
transform(value: unknown[], property: string): number | "" {
const mappedData =
value.length < 1
? [0]
: value
.map((res) => res[property])
.map((res) => (res ? parseFloat(res) : 0));
const result = mappedData.reduce((a, b) => a + b);
return isNaN(result) ? "" : result;
}
} I'd like to point out that this is a very basic implementation and will sum things that shouldn't be summed in the first place eg: Dates |
Beta Was this translation helpful? Give feedback.
-
Allow column aggregation, for example, sum of a numeric column.
The aggregation feature will first require an elegant design that does not
really aggregate but accepts aggregators that do the aggregation as well as a reactive mechanizm to update when data changes (not only from DS but from edits...)
Once in place, several aggregators should be implemented and provided in a core/plugin package, such can be Sum, Avg, Mean, STDV, etc... (think EXCEL)
In addition, supporting UI components will be required (or examples?) to display the aggregated data.
Beta Was this translation helpful? Give feedback.
All reactions