New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Table] Add a footer row (e.g. totals) #7548
Comments
See #6570 |
@andrewseguin it's probably worth talking about a more convenient shortcut for adding a summary row at some point |
To be clear - this is meant to be a sticky footer at the bottom rather than a "last row"? |
I think so, but we should collect a few use-cases before committing to anything. |
Since the table itself doesn't have knowledge of its scrollable container (its just a repeat of rows), I wonder if this would be out of scope. We should definitely chat more about this (and the sections feature seems similar actually). In the meantime, a solution to this would be to create a new table and append it right after the initial table. Hide the header row and keep the column IDs similar (to re-use any column-specific class styles you might have). This way, the table can be its own scrollable and the footer could just append right after the scrolling container. A separate data source should be provided since the data is unique. Here's a proof of concept Unfortunately most browsers push content left when a scrollbar appears, so it's likely that the columns will be misaligned for most users :( Edit: Reminds me of a simple solution for sticky headers as well =P |
I was making this to supplement #6570 (comment), but figure I'll add it here as an alternative solution in the mean-time, https://stackblitz.com/edit/material2-beta12-fkcu2t cc @Tempus35 |
@willshowell Thanks! |
This is a very important feature for a datatable. Since datatables are used mostly for showing numeric tabular data, totals is a must feature. |
@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. |
Such a nice table with lot of features but one of the most critical features of tabular data is missing. This missing feature prevents me from using material datatable. |
I agree, this is something that is used all the time with tables. |
Definitely still on our radar. Will likely call this something like Unfortunately its |
I think it already became quite simple to setup the table compared to previous versions. Never mind though didnt have morentime to wait switched to another table already. Keep up the good work |
@willshowell how can i use your solution on my async datasource ?
|
@GoLucas you could try something like this: interface Payment {
date: Date;
cost: number;
}
interface PaymentTotal {
total: number;
}
// ...
connect(): Observable<(Payment | PaymentTotal }[]> {
return this.paymentsData.httpGetPayments(this.reservation_id)
// Append a 'total' row at the end
.map(payments => {
const paymentsSum = payments.reduce((accum, curr) => accum + curr.cost), 0);
return [...payments, { total: paymentsSum }];
});
} |
@willshowell i have one more question how can i get |
@GoLucas a simple way would be to save it in the datasource: // In your datasource
public totalRowIndex;
connect(): Observable<(Payment | PaymentTotal }[]> {
return this.paymentsData.httpGetPayments(this.reservation_id)
// Append a 'total' row at the end
.map(payments => {
const paymentsSum = payments.reduce((accum, curr) => accum + curr.cost), 0);
return [...payments, { total: paymentsSum }];
})
.do(payments => this.totalRowIndex = payments.length - 1);
} // In your component class
isLastRow = (data, index) => index === this.dataSource.totalRowIndex; |
i im initialize datasource on change event in select
when i move isLastRow on the top under Class i have one additional empty row. |
Is there any progress on this matter, or some ETA? |
Your component should have this as a property: E.g.
|
This works for me for detecting the last row...
Except it's still useless with sorting. |
Thanks, yup. I saw there's Just put this below
|
Hi any working total footer column on https://stackblitz.com example with paging and sorting |
Hi Mr.rain, |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
feature reques
What is the expected behavior?
Add total row:
Result:
Or something like md-pagination.
The text was updated successfully, but these errors were encountered: