{"record":{"id":"7efe8ee9e58828fe","repo":"angular/components","slug":"cdkselectioncolumn-missing-cdkselection-in-the-pa","errorCode":null,"errorMessage":"CdkSelectionColumn: missing CdkSelection in the parent","messagePattern":"CdkSelectionColumn: missing CdkSelection in the parent","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/selection/selection-column.ts","lineNumber":88,"sourceCode":"  /** Column name that should be used to reference this column. */\n  @Input('cdkSelectionColumnName')\n  get name(): string {\n    return this._name;\n  }\n  set name(name: string) {\n    this._name = name;\n\n    this._syncColumnDefName();\n  }\n  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  }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/selection/selection-column.ts#L70-L106","documentation":"CdkSelectionColumn injects/receives the parent CdkSelection to wire its checkbox column to the selection state. ngOnInit throws this dev-mode error when no parent CdkSelection was found, so the selection column has nothing to bind to. This is distinct from the missing-table check that follows in the same method.","triggerScenarios":"Using <cdk-selection-column> (a table header/body column component) outside a <cdk-selection> context, so this.selection is undefined during ngOnInit.","commonSituations":"Adding the selection column directly inside a plain cdk-table instead of one wrapped in cdk-selection; moving the column into a reused table component that lacks the cdk-selection wrapper; template refactoring that dropped the wrapper element.","solutions":["Wrap the table in CdkSelection: <cdk-selection [multiple]=\"true\"> <cdk-table>...<cdk-selection-column/></cdk-table> </cdk-selection>.","Ensure the selection column is declared within the cdk-selection subtree so the injection/parent lookup resolves.","Check imports: use the experimental selection module's components consistently (CdkSelection + CdkSelectionColumn from the same package)."],"exampleFix":"// before\n<cdk-table><th cdk-selection-column .../></cdk-table>\n// after\n<cdk-selection [multiple]=\"true\">\n  <cdk-table><th cdk-selection-column .../></cdk-table>\n</cdk-selection>","handlingStrategy":"validation","validationCode":"if (!tableHost.closest('cdk-selection')) {\n  throw new Error('cdk-selection-column must be used within cdk-selection');\n}","typeGuard":null,"tryCatchPattern":"ngOnInit() {\n  if (!this.selection) {\n    console.warn('cdk-selection-column requires a cdk-selection ancestor');\n    return; // skip column wiring\n  }\n}","preventionTips":["Wrap any table using cdk-selection-column in a cdk-selection component.","Keep the selection wrapper and the table in the same template scope.","Add a dev-time assertion/comment in shared table components noting the cdk-selection requirement."],"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"}