MCPcopy Index your code
hub / github.com/TanStack/table / AppComponent

Class AppComponent

examples/angular/column-pinning-sticky/src/app/app.component.ts:83–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 templateUrl: './app.component.html',
82})
83export class AppComponent {
84 readonly columns = signal([...defaultColumns])
85 readonly data = signal<Person[]>(makeData(30))
86 readonly columnVisibility = signal<VisibilityState>({})
87 readonly columnOrder = signal<ColumnOrderState>([])
88 readonly columnPinning = signal<ColumnPinningState>({})
89 readonly split = signal(false)
90
91 table = createAngularTable(() => ({
92 data: this.data(),
93 columns: this.columns(),
94 getCoreRowModel: getCoreRowModel(),
95 debugTable: true,
96 debugHeaders: true,
97 debugColumns: true,
98 columnResizeMode: 'onChange',
99 }))
100
101 stringifiedColumnPinning = computed(() => {
102 return JSON.stringify(this.table.getState().columnPinning)
103 })
104
105 readonly getCommonPinningStyles = (
106 column: Column<Person>
107 ): Record<string, any> => {
108 const isPinned = column.getIsPinned()
109 const isLastLeftPinnedColumn =
110 isPinned === 'left' && column.getIsLastColumn('left')
111 const isFirstRightPinnedColumn =
112 isPinned === 'right' && column.getIsFirstColumn('right')
113
114 return {
115 boxShadow: isLastLeftPinnedColumn
116 ? '-4px 0 4px -4px gray inset'
117 : isFirstRightPinnedColumn
118 ? '4px 0 4px -4px gray inset'
119 : undefined,
120 left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
121 right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
122 opacity: isPinned ? 0.95 : 1,
123 position: isPinned ? 'sticky' : 'relative',
124 width: `${column.getSize()}px`,
125 zIndex: isPinned ? 1 : 0,
126 }
127 }
128
129 randomizeColumns() {
130 this.table.setColumnOrder(
131 faker.helpers.shuffle(this.table.getAllLeafColumns().map(d => d.id))
132 )
133 }
134
135 rerender() {
136 this.data.set(makeData(5000))
137 }
138}

Callers

nothing calls this directly

Calls 3

makeDataFunction · 0.90
createAngularTableFunction · 0.90
getCoreRowModelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…