Jquery ngx datatable摘要行未使用列属性中的summaryFunc。此外,所有摘要值都包含为字符串 您的示例缺少引用。正确使用[summaryRow]=“enableSummary。虽然我确定这不是问题的原因,但我也有同样的想法。这不是问题所在。现在我

Jquery ngx datatable摘要行未使用列属性中的summaryFunc。此外,所有摘要值都包含为字符串 您的示例缺少引用。正确使用[summaryRow]=“enableSummary。虽然我确定这不是问题的原因,但我也有同样的想法。这不是问题所在。现在我,jquery,angular,github,angular5,ngx-datatable,Jquery,Angular,Github,Angular5,Ngx Datatable,ngx datatable摘要行未使用列属性中的summaryFunc。此外,所有摘要值都包含为字符串 您的示例缺少引用。正确使用[summaryRow]=“enableSummary。虽然我确定这不是问题的原因,但我也有同样的想法。这不是问题所在。现在我通过更新版本和一些与之相关的代码来修复它。Summary row问题在13.0.0版本中得到修复。感谢Ozitho的友好回复 <ngx-datatable class="material" [summaryRow]="e

ngx datatable摘要行未使用列属性中的summaryFunc。此外,所有摘要值都包含为字符串
您的示例缺少引用。正确使用
[summaryRow]=“enableSummary
。虽然我确定这不是问题的原因,但我也有同样的想法。这不是问题所在。现在我通过更新版本和一些与之相关的代码来修复它。Summary row问题在13.0.0版本中得到修复。感谢Ozitho的友好回复
<ngx-datatable class="material" 
        [summaryRow]="enableSummary 
        [summaryPosition]="summaryPosition"
        [summaryHeight]="'auto'"
        [columns]="columns"
        [columnMode]="'force'"
        [headerHeight]="50"
        [rowHeight]="'auto'"
        [rows]="rows">
      </ngx-datatable>
     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;    
      }