swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

summaryTemplate prevents summaryFunc from being invoked #1708

Open bureaug opened 5 years ago

bureaug commented 5 years ago

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

When using summaryFunc and summaryTemplate with a column, the function is never called. Only when summaryTemplate is removed, the summaryFunc is being invoked.

Expected behavior

summaryFunc should be invoked when using a template, too

Reproduction of the problem

As I am using translations in all of my template (via pipes) I' bound to use templates, too. In the following markup the summaryFunc will only be invoked if summaryTemplate is removed:

<ngx-datatable  
        [rows]="rawData"  
        columnMode="force"  
        [rowHeight]="50"  
        [summaryRow]="true"  
        summaryPosition="bottom"  
        [summaryHeight]="'auto'"  
        [messages]="{  
            'emptyMessage': ( 'ui.noDataAvailable' | translate )  
        }"  
        [scrollbarH]="false">  
        <ngx-datatable-column   
            [name]=" 'reports.fields.employee' | translate "  
            [summaryTemplate]="summEmp"  
            [summaryFunc]="summUniques"  
            prop="employeeId"   
            [cellTemplate]="nameTmp"></ngx-datatable-column>  
</ngx-datatable>  
<ng-template #summEmp let-value="value">  
<span>{{ value }} {{ 'ui.specimenKey' | translate }}</span>  
</ng-template> 

The template is being shown, albeit empty. If I remove summaryFunc from the markup, I get no value in the template. If I remove summaryTemplate I get the value displayed (but obviously not via my template).

It seems like #1485 is related to this.

What is the motivation / use case for changing the behavior?

It is sometimes very helpful to label the summary values, especially so when they represent a sum of something different, then the values in the column itself (or a derived value of those values, like uniques, length, etc).

Please tell us about your environment:

OSX 10.14.5

trungkmy commented 5 years ago

Hello! Any update for this issue?