| 85 | changeDetection: ChangeDetectionStrategy.OnPush, |
| 86 | }) |
| 87 | export class AppComponent { |
| 88 | readonly data = signal<Person[]>(makeData(10_000)) |
| 89 | readonly injector = inject(Injector) |
| 90 | |
| 91 | readonly autoResetPageIndex = signal(true) |
| 92 | |
| 93 | readonly table = createAngularTable(() => ({ |
| 94 | data: this.data(), |
| 95 | columns: defaultColumns, |
| 96 | defaultColumn: defaultColumn, |
| 97 | getCoreRowModel: getCoreRowModel(), |
| 98 | getFilteredRowModel: getFilteredRowModel(), |
| 99 | getPaginationRowModel: getPaginationRowModel(), |
| 100 | debugTable: true, |
| 101 | autoResetPageIndex: this.autoResetPageIndex(), |
| 102 | // Provide our updateData function to our table meta |
| 103 | meta: { |
| 104 | updateData: (rowIndex, columnId, value) => { |
| 105 | // Skip page index reset until after next rerender |
| 106 | this.autoResetPageIndex.set(false) |
| 107 | |
| 108 | this.data.update(old => |
| 109 | old.map((row, index) => { |
| 110 | if (index === rowIndex) { |
| 111 | return { |
| 112 | ...old[rowIndex], |
| 113 | [columnId]: value, |
| 114 | } |
| 115 | } |
| 116 | return row |
| 117 | }) |
| 118 | ) |
| 119 | |
| 120 | afterNextRender(() => this.autoResetPageIndex.set(true), { |
| 121 | injector: this.injector, |
| 122 | }) |
| 123 | }, |
| 124 | }, |
| 125 | })) |
| 126 | |
| 127 | refresh() { |
| 128 | this.data.set(makeData(10_000)) |
| 129 | } |
| 130 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…