Skip to content

Commit 92e5f55

Browse files
josephperrottmmalerba
authored andcommitted
fix(table): Allow any iterable to be used as for columns in headerrow and row defs (#10822)
1 parent 975fe7e commit 92e5f55

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cdk/table/row.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const CDK_ROW_TEMPLATE = `<ng-container cdkCellOutlet></ng-container>`;
3232
*/
3333
export abstract class BaseRowDef {
3434
/** The columns to be displayed on this row. */
35-
columns: string[];
35+
columns: Iterable<string>;
3636

3737
/** Differ used to check if any changes were made to the columns. */
3838
protected _columnsDiffer: IterableDiffer<any>;

src/cdk/table/table.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ export class CdkTable<T> implements CollectionViewer, OnInit, AfterContentChecke
535535
*/
536536
private _getHeaderCellTemplatesForRow(headerDef: CdkHeaderRowDef): CdkHeaderCellDef[] {
537537
if (!headerDef || !headerDef.columns) { return []; }
538-
return headerDef.columns.map(columnId => {
538+
return Array.from(headerDef.columns, columnId => {
539539
const column = this._columnDefsByName.get(columnId);
540540

541541
if (!column) {
@@ -546,13 +546,14 @@ export class CdkTable<T> implements CollectionViewer, OnInit, AfterContentChecke
546546
});
547547
}
548548

549+
549550
/**
550551
* Returns the cell template definitions to insert in the provided row
551552
* as defined by its list of columns to display.
552553
*/
553554
private _getCellTemplatesForRow(rowDef: CdkRowDef<T>): CdkCellDef[] {
554555
if (!rowDef.columns) { return []; }
555-
return rowDef.columns.map(columnId => {
556+
return Array.from(rowDef.columns, columnId => {
556557
const column = this._columnDefsByName.get(columnId);
557558

558559
if (!column) {

0 commit comments

Comments
 (0)