-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs(material/table): add docs on row/column styles and bindings #22778
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c6060b
docs(material/table): add docs on row/column styles and bindings
andrewseguin 70c31a4
docs(material/table): fix CSS classname to match demo-
andrewseguin c355963
docs(material/table): review
andrewseguin 1928bd8
docs(material/table): review2
andrewseguin f1090ac
docs(material/table): use set
andrewseguin 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
src/components-examples/material/table/table-column-styling/table-column-styling-example.css
This file contains hidden or 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,25 @@ | ||
.demo-table { | ||
width: 100%; | ||
} | ||
|
||
.mat-column-demo-position { | ||
width: 32px; | ||
border-right: 1px solid currentColor; | ||
padding-right: 24px; | ||
text-align: center; | ||
} | ||
|
||
.mat-column-demo-name { | ||
padding-left: 16px; | ||
font-size: 20px; | ||
} | ||
|
||
.mat-column-demo-weight { | ||
font-style: italic; | ||
} | ||
|
||
.mat-column-demo-symbol { | ||
width: 32px; | ||
text-align: center; | ||
font-weight: bold; | ||
} |
29 changes: 29 additions & 0 deletions
29
...components-examples/material/table/table-column-styling/table-column-styling-example.html
This file contains hidden or 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,29 @@ | ||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> | ||
<!-- Position Column --> | ||
<ng-container matColumnDef="demo-position"> | ||
<th mat-header-cell *matHeaderCellDef> No. </th> | ||
<td mat-cell *matCellDef="let element"> {{element.position}} </td> | ||
</ng-container> | ||
|
||
<!-- Name Column --> | ||
<ng-container matColumnDef="demo-name"> | ||
<th mat-header-cell *matHeaderCellDef> Name </th> | ||
<td mat-cell *matCellDef="let element"> {{element.name}} </td> | ||
</ng-container> | ||
|
||
<!-- Weight Column --> | ||
<ng-container matColumnDef="demo-weight"> | ||
<th mat-header-cell *matHeaderCellDef> Weight </th> | ||
<td mat-cell *matCellDef="let element"> {{element.weight}} </td> | ||
</ng-container> | ||
|
||
<!-- Symbol Column --> | ||
<ng-container matColumnDef="demo-symbol"> | ||
<th mat-header-cell *matHeaderCellDef> Symbol </th> | ||
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
|
34 changes: 34 additions & 0 deletions
34
src/components-examples/material/table/table-column-styling/table-column-styling-example.ts
This file contains hidden or 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,34 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
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'}, | ||
]; | ||
|
||
/** | ||
* @title Styling columns using their auto-generated column names | ||
*/ | ||
@Component({ | ||
selector: 'table-column-styling-example', | ||
styleUrls: ['table-column-styling-example.css'], | ||
templateUrl: 'table-column-styling-example.html', | ||
}) | ||
export class TableColumnStylingExample { | ||
displayedColumns: string[] = ['demo-position', 'demo-name', 'demo-weight', 'demo-symbol']; | ||
dataSource = ELEMENT_DATA; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/components-examples/material/table/table-row-binding/table-row-binding-example.css
This file contains hidden or 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,17 @@ | ||
.demo-table { | ||
andrewseguin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width: 100%; | ||
} | ||
|
||
.mat-row .mat-cell { | ||
border-bottom: 1px solid transparent; | ||
border-top: 1px solid transparent; | ||
cursor: pointer; | ||
} | ||
|
||
.mat-row:hover .mat-cell { | ||
border-color: currentColor; | ||
} | ||
|
||
.demo-row-is-clicked { | ||
font-weight: bold; | ||
} |
49 changes: 49 additions & 0 deletions
49
src/components-examples/material/table/table-row-binding/table-row-binding-example.html
This file contains hidden or 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,49 @@ | ||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table"> | ||
<!-- 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> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr | ||
mat-row | ||
(click)="clickedRows.add(row)" | ||
[class.demo-row-is-clicked]="clickedRows.has(row)" | ||
*matRowDef="let row; columns: displayedColumns;" | ||
></tr> | ||
</table> | ||
|
||
<div> | ||
<h3> | ||
Click Log | ||
</h3> | ||
</div> | ||
|
||
<div *ngIf="!clickedRows.size"> | ||
Clicked rows will be logged here | ||
</div> | ||
|
||
<ul> | ||
<li *ngFor="let clickedRow of clickedRows"> | ||
Clicked on {{clickedRow.name}} | ||
</li> | ||
</ul> |
35 changes: 35 additions & 0 deletions
35
src/components-examples/material/table/table-row-binding/table-row-binding-example.ts
This file contains hidden or 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,35 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
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'}, | ||
]; | ||
|
||
/** | ||
* @title Binding event handlers and properties to the table rows. | ||
*/ | ||
@Component({ | ||
selector: 'table-row-binding-example', | ||
styleUrls: ['table-row-binding-example.css'], | ||
templateUrl: 'table-row-binding-example.html', | ||
}) | ||
export class TableRowBindingExample { | ||
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; | ||
dataSource = ELEMENT_DATA; | ||
clickedRows = new Set<PeriodicElement>(); | ||
} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.