[Table] Add a footer row (e.g. totals)
See original GitHub issueBug, feature request, or proposal:
feature reques
What is the expected behavior?
Add total row:
<md-table [dataSource]="dataSource">
<!-- Name Column -->
<ng-container mdColumnDef="name">
<md-header-cell *mdHeaderCellDef> Name </md-header-cell>
<md-cell *mdCellDef="let row"> {{row.name}} </md-cell>
<md-total-cell *mdTotalCellDef> Total </md-total-cell>
</ng-container>
<!-- Count Column -->
<ng-container mdColumnDef="count">
<md-header-cell *mdHeaderCellDef> Count </md-header-cell>
<md-cell *mdCellDef="let row"> {{row.count}} </md-cell>
<md-total-cell *mdTotalCellDef> {{dataSource.sumBy('count')}} </md-total-cell>
</ng-container>
<md-header-row *mdHeaderRowDef="displayedColumns"></md-header-row>
<md-row *mdRowDef="let row; columns: displayedColumns;"></md-row>
<md-total-row *mdTotalRowDef="displayedColumns"></md-total-row>
</md-table>
Result:
Name Count
row 1 1
row 2 2
Total 3
Or something like md-pagination.
<md-table [dataSource]="dataSource">
<!-- Name Column -->
<ng-container mdColumnDef="name">
<md-header-cell *mdHeaderCellDef> Name </md-header-cell>
<md-cell *mdCellDef="let row"> {{row.name}} </md-cell>
</ng-container>
<!-- Count Column -->
<ng-container mdColumnDef="count">
<md-header-cell *mdHeaderCellDef> Count </md-header-cell>
<md-cell *mdCellDef="let row"> {{row.count}} </md-cell>
</ng-container>
<md-header-row *mdHeaderRowDef="displayedColumns"></md-header-row>
<md-row *mdRowDef="let row; columns: displayedColumns;"></md-row>
</md-table>
<md-table-total [dataSource]="dataSource">
<!-- Name Column -->
<ng-container mdColumnDef="name">
<md-total-cell *mdTotalCellDef> Total </md-total-cell>
</ng-container>
<!-- Count Column -->
<ng-container mdColumnDef="count">
<md-total-cell *mdTotalCellDef> {{dataSource.sumBy('count')}} </md-total-cell>
</ng-container>
</md-table-total>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:27 (11 by maintainers)
Top Results From Across the Web
Add a Total Row to the footer of html table
Solved: I am running a SQL query that outputs the below There are more than 3 EventTypes (maybe 12 in total), but I've...
Read more >Sum a column of numbers in a repeating table
In the footer row, click the cell in the column where you want to add the Total box. · On the Insert menu,...
Read more >How to enable or show total row in footer of ag-grid table
1st step - Generate Pinned Total Row: Below function will generate an empty target object with all your columns available in the grid....
Read more >Adding a total in the footer. — DataTables forums
Hello Forums, I am using DataTables for the first time. I came to this problem where I need the sum of rows in...
Read more >Footer callback - DataTables example
The example below shows a footer callback being used to total the data for a column (both the visible and the hidden data)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andrewseguin Why is this minor? Is there any workaround that works without any issues? From what you said your workaround above does not work well. 😃
I was just wondering if the discussion was still happening on this or if this is dead in the water. Could really use this in my current project.