angular / angular/components

Support inserting row/column defs at specific indices rather than always appending

Open
#21,791 7 comments 2 reactions 0 assignees View on GitHub
area: cdk/table feature P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### What are you trying to do?

I'm trying to make table with 2 sticky header rows. First row should contain toolbar with table actions, but definition of this row is in separated file, it is passed through `cdkTable.addHeaderRowDef` . Second row should contain descriptions of columns.

#### What troubleshooting steps have you tried?

I tried to manually position `headerRowDefinition` inside `_headerRowDefs` property, but I'm unable to do that due to:
https://github.com/angular/components/blob/d3deb8b9c61f79f6a4ab75d74914aac3b43592bf/src/cdk/table/table.ts#L895
contentHeaderRowDefinitions specified explicit as content are always before customHeaderRowDefinitions added via `addHeaderRowDef`.

I tried to handle stickness by styling headers `postion: sticky` and calculate top positioning, but I'm unable to do that due to: https://github.com/angular/components/blob/d3deb8b9c61f79f6a4ab75d74914aac3b43592bf/src/cdk/table/table.ts#L731
All header rows have cleared top positioning value that I set via styling.

#### Reproduction
https://stackblitz.com/edit/angular-bkarpk?file=src/app/table/table.component.html

#### Environment

- Angular: 11.1.1
- CDK/Material: 11.1.1
- Browser(s): Chrome/Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Contributor guide

Open the contributing guide

Research direction

Start with the linked sections of src/cdk/table/table.ts and run the provided StackBlitz reproduction. Trace how content and custom header row definitions are ordered and how sticky header positioning is cleared. Done means header definitions can appear at the requested index and the two sticky header rows retain correct positioning.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.