feat(table): add the ability to show a data row when no data is available#18041
feat(table): add the ability to show a data row when no data is available#18041jelbourn merged 1 commit intoangular:masterfrom
Conversation
|
|
||
| /** Row that can be used to display a message when no data is shown in the table. */ | ||
| @Directive({ | ||
| selector: 'ng-template[cdkNoDataRow]' |
There was a problem hiding this comment.
The name of the directive sounds a little clunky, but I couldn't come up with anything more descriptive. I'm open ideas on how to name it better.
There was a problem hiding this comment.
The term "placeholder" comes to (my) mind but I'm not sure it'd be adequate here.
I'd somewhat like to have all the elements that are "placeholders" of some sort identified as such across all the components that use them. Not just all the placeholders in particular, but all the elements that are (semantically) somewhat agnostic to the "collection" they belong to in general.
A reusable naming convention makes for a conceptually simpler API!
I think the CDK Drag&Drop uses something like cdkDragPlaceholder, so maybe cdkNoDataPlaceholder would be acceptable... but I don't like it, it's clunkier than cdkNoDataRow ever was 🤪
Disclaimer: I really haven't thought this through, this is just my two cents.
There was a problem hiding this comment.
Having "placeholder" in there sounds good to me since this behaves a little bit like the native input placeholder (e.g. something that shows up when the input is empty).
9f1409b to
ca6e0aa
Compare
|
I'm not totally sold that we'd want to add this to the table. You can accomplish the same thing today by:
We could explicitly document this pattern without needing to add any additional code or concepts to the table. |
|
How would you handle the placeholder row having a different amount of cells compared to regular rows? You don't need a full row of cells just to say "No more data". |
|
I was thinking something like this <table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element">{{item.name}}</td>
</ng-container>
<!-- ... other data columns ... -->
<!-- Empty data placeholder -->
<ng-container matColumnDef="empty-placeholder">
<td mat-cell *matCellDef colspan="3">No results found</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="['name', 'age', 'address']"></tr>
<tr mat-row *matRowDef="let row; columns: ['name', 'age', 'address'];"></tr>
<tr mat-row *matRowDef="let row; columns: ['empty-placeholder']; when: isEmptyRow"></tr>
</table>We can chat about it during this week's team meeting |
|
Based on discussion, we will go ahead with this. I propose using |
ca6e0aa to
afad09e
Compare
|
@jelbourn I've changed the naming to |
jelbourn
left a comment
There was a problem hiding this comment.
LGTM, just needs rebase
afad09e to
ac946b3
Compare
|
Rebased. |
|
any updates? |
ac946b3 to
386d590
Compare
386d590 to
fa9f419
Compare
…able As the table is set up at the moment, there's no convenient way to show the user something when their filtered table didn't match any data. These changes add a new directive that renders out a single row when no other data is available which can be used to show a message.
fa9f419 to
9cc038f
Compare
…is available (angular#18041)" This reverts commit e512581.
…able (angular#18041) As the table is set up at the moment, there's no convenient way to show the user something when their filtered table didn't match any data. These changes add a new directive that renders out a single row when no other data is available which can be used to show a message.
|
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. |
As the table is set up at the moment, there's no convenient way to show the user something when their filtered table didn't match any data. These changes add a new directive that renders out a single row when no other data is available which can be used to show a message.