param table default sorting

This commit is contained in:
Cyril Joseph 2026-01-12 22:20:29 -04:00
parent 0da6daaa85
commit 602793d2a4

View File

@ -64,14 +64,28 @@ export class ParamTableComponent {
@ViewChild(MatSort, { static: false })
set sort(value: MatSort) {
this.dataSource.sort = value;
if (value) {
// 1. Assign the sort object to the data source immediately
this.dataSource.sort = value;
// 2. Apply default settings inside a timeout to avoid the NG0100 error
setTimeout(() => {
if (this.table_mode === 'TABLE-RECORD' && !value.active) {
// Only set default if a sort isn't already active
value.active = 'paramValue';
value.direction = 'asc';
// 3. Instead of emitting an event, manually trigger the sort logic
// through the DataSource's internal sortingDataAccessor
this.dataSource.sort = value;
}
});
}
}
paramForm: FormGroup;
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.dataSource.data = this.paramData;
}