diff --git a/src/app/param/table/param-table.component.ts b/src/app/param/table/param-table.component.ts index 22eb70f..6bbba08 100644 --- a/src/app/param/table/param-table.component.ts +++ b/src/app/param/table/param-table.component.ts @@ -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; }