@@ -88,7 +88,7 @@ export class CdkTable<T> implements CollectionViewer {
88
88
private _renderChangeSubscription : Subscription | null ;
89
89
90
90
/** 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 > ( ) ;
92
92
93
93
/** Differ used to find the changes in the data provided by the data source. */
94
94
private _dataDiffer : IterableDiffer < T > ;
@@ -170,6 +170,7 @@ export class CdkTable<T> implements CollectionViewer {
170
170
}
171
171
172
172
ngAfterContentChecked ( ) {
173
+ this . _renderUpdatedColumns ( ) ;
173
174
this . _cacheColumnDefinitionsByName ( ) ;
174
175
}
175
176
@@ -204,20 +205,20 @@ export class CdkTable<T> implements CollectionViewer {
204
205
205
206
/** Update the map containing the content's column definitions. */
206
207
private _cacheColumnDefinitionsByName ( ) {
207
- this . _columnDefinitionsMap . clear ( ) ;
208
+ this . _columnDefinitionsByName . clear ( ) ;
208
209
this . _columnDefinitions . forEach ( columnDef => {
209
- if ( this . _columnDefinitionsMap . has ( columnDef . name ) ) {
210
+ if ( this . _columnDefinitionsByName . has ( columnDef . name ) ) {
210
211
throw getTableDuplicateColumnNameError ( columnDef . name ) ;
211
212
}
212
- this . _columnDefinitionsMap . set ( columnDef . name , columnDef ) ;
213
+ this . _columnDefinitionsByName . set ( columnDef . name , columnDef ) ;
213
214
} ) ;
214
215
}
215
216
216
217
/**
217
218
* Check if the header or rows have changed what columns they want to display. If there is a diff,
218
219
* then re-render that section.
219
220
*/
220
- private _checkColumnsChange ( ) {
221
+ private _renderUpdatedColumns ( ) {
221
222
// Re-render the rows when the row definition columns change.
222
223
this . _rowDefinitions . forEach ( def => {
223
224
if ( ! ! def . getColumnsDiff ( ) ) {
@@ -366,7 +367,7 @@ export class CdkTable<T> implements CollectionViewer {
366
367
private _getHeaderCellTemplatesForRow ( headerDef : CdkHeaderRowDef ) : CdkHeaderCellDef [ ] {
367
368
if ( ! headerDef . columns ) { return [ ] ; }
368
369
return headerDef . columns . map ( columnId => {
369
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
370
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
370
371
371
372
if ( ! column ) {
372
373
throw getTableUnknownColumnError ( columnId ) ;
@@ -383,7 +384,7 @@ export class CdkTable<T> implements CollectionViewer {
383
384
private _getCellTemplatesForRow ( rowDef : CdkRowDef ) : CdkCellDef [ ] {
384
385
if ( ! rowDef . columns ) { return [ ] ; }
385
386
return rowDef . columns . map ( columnId => {
386
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
387
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
387
388
388
389
if ( ! column ) {
389
390
throw getTableUnknownColumnError ( columnId ) ;
0 commit comments