Skip to content

Commit 3e1a21d

Browse files
committed
review
1 parent 782c940 commit 3e1a21d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/cdk/table/table.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class CdkTable<T> implements CollectionViewer {
8888
private _renderChangeSubscription: Subscription | null;
8989

9090
/** Map of all the user's defined columns (header and data cell template) identified by name. */
91-
private _columnDefinitionsMap = new Map<string, CdkColumnDef>();
91+
private _columnDefinitionsByName = new Map<string, CdkColumnDef>();
9292

9393
/** Differ used to find the changes in the data provided by the data source. */
9494
private _dataDiffer: IterableDiffer<T>;
@@ -170,6 +170,7 @@ export class CdkTable<T> implements CollectionViewer {
170170
}
171171

172172
ngAfterContentChecked() {
173+
this._renderUpdatedColumns();
173174
this._cacheColumnDefinitionsByName();
174175
}
175176

@@ -204,20 +205,20 @@ export class CdkTable<T> implements CollectionViewer {
204205

205206
/** Update the map containing the content's column definitions. */
206207
private _cacheColumnDefinitionsByName() {
207-
this._columnDefinitionsMap.clear();
208+
this._columnDefinitionsByName.clear();
208209
this._columnDefinitions.forEach(columnDef => {
209-
if (this._columnDefinitionsMap.has(columnDef.name)) {
210+
if (this._columnDefinitionsByName.has(columnDef.name)) {
210211
throw getTableDuplicateColumnNameError(columnDef.name);
211212
}
212-
this._columnDefinitionsMap.set(columnDef.name, columnDef);
213+
this._columnDefinitionsByName.set(columnDef.name, columnDef);
213214
});
214215
}
215216

216217
/**
217218
* Check if the header or rows have changed what columns they want to display. If there is a diff,
218219
* then re-render that section.
219220
*/
220-
private _checkColumnsChange() {
221+
private _renderUpdatedColumns() {
221222
// Re-render the rows when the row definition columns change.
222223
this._rowDefinitions.forEach(def => {
223224
if (!!def.getColumnsDiff()) {
@@ -366,7 +367,7 @@ export class CdkTable<T> implements CollectionViewer {
366367
private _getHeaderCellTemplatesForRow(headerDef: CdkHeaderRowDef): CdkHeaderCellDef[] {
367368
if (!headerDef.columns) { return []; }
368369
return headerDef.columns.map(columnId => {
369-
const column = this._columnDefinitionsMap.get(columnId);
370+
const column = this._columnDefinitionsByName.get(columnId);
370371

371372
if (!column) {
372373
throw getTableUnknownColumnError(columnId);
@@ -383,7 +384,7 @@ export class CdkTable<T> implements CollectionViewer {
383384
private _getCellTemplatesForRow(rowDef: CdkRowDef): CdkCellDef[] {
384385
if (!rowDef.columns) { return []; }
385386
return rowDef.columns.map(columnId => {
386-
const column = this._columnDefinitionsMap.get(columnId);
387+
const column = this._columnDefinitionsByName.get(columnId);
387388

388389
if (!column) {
389390
throw getTableUnknownColumnError(columnId);

src/demo-app/table/table-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
</div>
2121

22-
<md-card>
22+
<md-card class="demo-table-card">
2323
<h3>
2424
CdkTable With Dynamic Column Def
2525
<div>
@@ -47,7 +47,7 @@ <h3>
4747
</cdk-table>
4848
</md-card>
4949

50-
<md-card>
50+
<md-card class="demo-table-card">
5151
<h3>CdkTable Example</h3>
5252

5353
<div class="demo-highlighter">

src/demo-app/table/table-demo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.demo-row-highlight-even { background: #ff0099; }
2323
.demo-row-highlight-odd { background: #83f52c; }
2424

25-
.mat-card {
25+
.demo-table-card {
2626
margin: 24px 0;
2727
max-height: 200px;
2828
overflow: auto;

0 commit comments

Comments
 (0)