Skip to content

feat(aria/grid): add CDK table interop - #33859

Open
TomaszKasowicz wants to merge 1 commit into
angular:mainfrom
TomaszKasowicz:feat-ngrid-cdk-interop
Open

TomaszKasowicz wants to merge 1 commit into
angular:mainfrom
TomaszKasowicz:feat-ngrid-cdk-interop

Conversation

@TomaszKasowicz

@TomaszKasowicz TomaszKasowicz commented Sep 23, 2026

Copy link
Copy Markdown

Adds interoperability directives which allow users to use ngGrid with CDK tables. In native table <tr ngGridRow> is always a parent of <td ngGridCell>. However in CDK table <td> elements are defined outside of <tr> elements. This commit adds directives which allow users to bridge ngGridRow and ngGridCell. Usage:

@Component({
  template: `
    <table cdk-table role="grid" ngGrid>
      <ng-container cdkColumnDef="name">
        <th ngGridCell ngProvideGridRowForCdk cdk-header-cell *cdkHeaderCellDef>Name</th>
        <td ngGridCell ngProvideGridRowForCdk cdk-cell *cdkCellDef="let row">{{ row.name }}</td>
      </ng-container>
    <tr ngGridRow ngRegisterGridRowForCdk cdk-header-row *cdkHeaderRowDef="displayedColumns"></tr>
    <tr ngGridRow ngRegisterGridRowForCdk cdk-row *cdkRowDef="let row; columns: displayedColumns"></tr>
    </table>
  `,
  providers: [NgGridRowRegistryForCdk],
})
export class CdkTableInteropComponent {
  readonly displayedColumns = ['name'];
}

NOTE: This is a proposal. Feel free to reject this PR if You think it's not suitable

Fixes: #32603

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: aria/grid labels Sep 23, 2026
Adds interoperability directives which allow users to use `ngGrid` with CDK tables.
In native table `<tr ngGridRow>` is always a parent of `<td ngGridCell>`.
However in CDK table `<td>` elements are defined outside of `<tr>` elements.
This commit adds directives which allow users to bridge `ngGridRow` and `ngGridCell`.
Usage:
```typescript
@component({
  template: `
    <table cdk-table role="grid" ngGrid>
      <ng-container cdkColumnDef="name">
        <th ngGridCell ngProvideGridRowForCdk cdk-header-cell *cdkHeaderCellDef>Name</th>
        <td ngGridCell ngProvideGridRowForCdk cdk-cell *cdkCellDef="let row">{{ row.name }}</td>
      </ng-container>
    <tr ngGridRow ngRegisterGridRowForCdk cdk-header-row *cdkHeaderRowDef="displayedColumns"></tr>
    <tr ngGridRow ngRegisterGridRowForCdk cdk-row *cdkRowDef="let row; columns: displayedColumns"></tr>
    </table>
  `,
  providers: [NgGridRowRegistryForCdk],
})
export class CdkTableInteropComponent {
  readonly displayedColumns = ['name'];
}
```

Fixes: angular#32603

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: aria/grid detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(aria-grid): ngGridCell fails with NG0201 (No provider found for GRID_ROW) when used inside cdk-table

1 participant