{"record":{"id":"e40edb44bc58ea37","repo":"angular/components","slug":"cdkselectioncolumn-missing-parent-table","errorCode":null,"errorMessage":"CdkSelectionColumn: missing parent table","messagePattern":"CdkSelectionColumn: missing parent table","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/selection/selection-column.ts","lineNumber":98,"sourceCode":"  private _name!: string;\n\n  @ViewChild(CdkColumnDef, {static: true}) private readonly _columnDef!: CdkColumnDef;\n  @ViewChild(CdkCellDef, {static: true}) private readonly _cell!: CdkCellDef;\n  @ViewChild(CdkHeaderCellDef, {static: true}) private readonly _headerCell!: CdkHeaderCellDef;\n\n  ngOnInit() {\n    if (!this.selection && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelectionColumn: missing CdkSelection in the parent');\n    }\n\n    this._syncColumnDefName();\n\n    if (this._table) {\n      this._columnDef.cell = this._cell;\n      this._columnDef.headerCell = this._headerCell;\n      this._table.addColumnDef(this._columnDef);\n    } else if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      throw Error('CdkSelectionColumn: missing parent table');\n    }\n  }\n\n  ngOnDestroy() {\n    if (this._table) {\n      this._table.removeColumnDef(this._columnDef);\n    }\n  }\n\n  private _syncColumnDefName() {\n    if (this._columnDef) {\n      this._columnDef.name = this._name;\n    }\n  }\n}\n","sourceCodeStart":80,"sourceCodeEnd":114,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/selection/selection-column.ts#L80-L114","documentation":"CdkSelectionColumn registers its CdkColumnDef (cell/header cell definitions) with a parent CdkTable via addColumnDef. When the component is not rendered inside a CDK table, this._table is undefined and ngOnInit throws this dev-mode error instead of silently failing to register the column. Without a table the column has no rendering target.","triggerScenarios":"Placing <cdk-selection-column> (or its th/td markup) outside any <cdk-table>/mat-table so the injected table reference is undefined when ngOnInit runs.","commonSituations":"Using the selection column markup in a plain HTML table or a custom non-CDK table; accidentally nesting it in a wrapper that breaks content projection into the table; typos in selectors so the table child query misses.","solutions":["Render the selection column inside a <cdk-table> (or MatTable) so the table can be injected and the column registered.","Verify the element is a direct part of the table's projected content (inside th/td rows of cdk-table), not a detached wrapper.","Check that you imported/declared both the table and selection-column components from the experimental selection/tables modules."],"exampleFix":"// before\n<cdk-selection><th cdk-selection-column/></cdk-selection>\n// after\n<cdk-selection [multiple]=\"true\">\n  <cdk-table [dataSource]=\"data\">\n    <ng-container cdkColumnDef=\"select\">\n      <th cdk-header-cell cdk-selection-column *cdkHeaderCellDef></th>\n    </ng-container>\n  </cdk-table>\n</cdk-selection>","handlingStrategy":"validation","validationCode":"if (!document.querySelector('cdk-table, mat-table')) {\n  // selection column has no table to register with\n}","typeGuard":null,"tryCatchPattern":"ngAfterContentInit() {\n  if (!this._table) {\n    throw new Error('cdk-selection-column must be placed inside a cdk-table');\n  }\n}","preventionTips":["Only use cdk-selection-column inside a CDK/Material table's column definitions.","Avoid wrapping table headers in extra components that break content projection into the table.","Test that column registration works by asserting the checkbox header renders in a smoke test."],"tags":["angular","cdk","selection","table","missing-parent"],"backgroundTag":"missing-parent-component","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}