-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
docs(material/table): table multiple row example #27621 #29421
Open
HermanWKeuris
wants to merge
1
commit into
angular:main
Choose a base branch
from
HermanWKeuris:table-multi-row-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...amples/material/table/table-multiple-row-template/table-multiple-row-template-example.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table { | ||
width: 100%; | ||
} |
38 changes: 38 additions & 0 deletions
38
...mples/material/table/table-multiple-row-template/table-multiple-row-template-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div class="mat-elevation-z8"> | ||
<table mat-table [dataSource]="dataSource" multiTemplateDataRows> | ||
|
||
<!-- Position Column --> | ||
<ng-container matColumnDef="position"> | ||
<th mat-header-cell *matHeaderCellDef> No. </th> | ||
<td mat-cell *matCellDef="let element"> {{element.position}} </td> | ||
</ng-container> | ||
|
||
<!-- Name Column --> | ||
<ng-container matColumnDef="name"> | ||
<th mat-header-cell *matHeaderCellDef> Name </th> | ||
<td mat-cell *matCellDef="let element"> {{element.name}} </td> | ||
</ng-container> | ||
|
||
<!-- Weight Column --> | ||
<ng-container matColumnDef="weight"> | ||
<th mat-header-cell *matHeaderCellDef> Weight </th> | ||
<td mat-cell *matCellDef="let element"> {{element.weight}} </td> | ||
</ng-container> | ||
|
||
<!-- Symbol Column --> | ||
<ng-container matColumnDef="symbol"> | ||
<th mat-header-cell *matHeaderCellDef> Symbol </th> | ||
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td> | ||
</ng-container> | ||
|
||
<!-- Secondary Column --> | ||
<ng-container matColumnDef="secondary"> | ||
<td mat-cell [attr.colspan]="displayedColumns.length" | ||
*matCellDef="let element"> Secondary row for the element {{element.name}} </td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
<tr mat-row *matRowDef="let row; columns: ['secondary'];"></tr> | ||
</table> | ||
</div> |
47 changes: 47 additions & 0 deletions
47
...xamples/material/table/table-multiple-row-template/table-multiple-row-template-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Component} from '@angular/core'; | ||
import {MatTableDataSource, MatTableModule} from '@angular/material/table'; | ||
|
||
/** | ||
* @title Table with multiple row template | ||
*/ | ||
@Component({ | ||
selector: 'table-multiple-row-template-example', | ||
styleUrls: ['table-multiple-row-template-example.css'], | ||
templateUrl: 'table-multiple-row-template-example.html', | ||
standalone: true, | ||
imports: [MatTableModule], | ||
}) | ||
export class TableMultipleRowTemplateExample { | ||
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; | ||
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); | ||
} | ||
|
||
export interface PeriodicElement { | ||
name: string; | ||
position: number; | ||
weight: number; | ||
symbol: string; | ||
} | ||
|
||
const ELEMENT_DATA: PeriodicElement[] = [ | ||
{position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, | ||
{position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, | ||
{position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, | ||
{position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, | ||
{position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, | ||
{position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, | ||
{position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, | ||
{position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, | ||
{position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, | ||
{position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, | ||
{position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'}, | ||
{position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'}, | ||
{position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'}, | ||
{position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'}, | ||
{position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'}, | ||
{position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'}, | ||
{position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'}, | ||
{position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'}, | ||
{position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'}, | ||
{position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation in this file and the .css one above looks off. It's probably using tabs instead of spaces.