<ngx-datatable class="material"
[summaryRow]="enableSummary
[summaryPosition]="summaryPosition"
[summaryHeight]="'auto'"
[columns]="columns"
[columnMode]="'force'"
[headerHeight]="50"
[rowHeight]="'auto'"
[rows]="rows">
</ngx-datatable>
Код машинописного текста: здесь для свойства name я добавил null в качестве summaryFunc.тем не менее он объединяет всех nammes
rows = [];
enableSummary = true;
summaryPosition = 'top';
columns = [
{ prop: 'name', summaryFunc: null, },
{ name: 'Gender', summaryFunc: (cells) => this.summaryForGender(cells) },
{ prop: 'age', summaryFunc: (cells) => this.avgAge(cells) },
];
private summaryForGender(cells: string[]) {
const males = cells.filter(cell => cell === 'male').length;
const females = cells.filter(cell => cell === 'female').length;
return `males: ${males}, females: ${females}`;
}
private avgAge(cells: number[]): number {
const filteredCells = cells.filter(cell => !!cell);
return filteredCells.reduce((sum, cell) => sum += cell, 0) / filteredCells.length;
}