Skip to content

Commit 9026efa

Browse files
feat: table sort change output (#1438)
1 parent cd92c76 commit 9026efa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

projects/components/src/table/table.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ export class TableComponent
307307
@Output()
308308
public readonly columnConfigsChange: EventEmitter<TableColumnConfig[]> = new EventEmitter<TableColumnConfig[]>();
309309

310+
@Output()
311+
public readonly sortChange: EventEmitter<SortedColumn> = new EventEmitter<SortedColumn>();
312+
310313
@ViewChild(PaginatorComponent)
311314
public paginator?: PaginatorComponent;
312315

@@ -537,10 +540,12 @@ export class TableComponent
537540

538541
public onSortChange(direction: TableSortDirection, columnConfig: TableColumnConfigExtended): void {
539542
if (TableCdkColumnUtil.isColumnSortable(columnConfig)) {
540-
this.updateSort({
543+
const sortedColumn: SortedColumn = {
541544
column: columnConfig,
542545
direction: direction
543-
});
546+
};
547+
this.sortChange.emit(sortedColumn);
548+
this.updateSort(sortedColumn);
544549
}
545550

546551
if (this.syncWithUrl) {
@@ -775,7 +780,7 @@ export class TableComponent
775780
}
776781
}
777782

778-
interface SortedColumn {
783+
export interface SortedColumn {
779784
column: TableColumnConfigExtended;
780785
direction?: TableSortDirection;
781786
}

0 commit comments

Comments
 (0)