sortable
选项。我做了一些actoin,但是没有用。
这是我的数据源:
export class ArticleCommentDataSource implements DataSource<any> {
constructor(private articleCommentService: ArticleCommentService) {
}
loadNewsComment(
pageIndex: number,
pageSize: number,
filters: TableFilterRules[]
): void {
this.articleCommentService.GetAll(this.searchParam)
.pipe(
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false))
)
.subscribe((gift: TablePagingIndex<Comment>) => {
const data = gift.records;
this.articleCommentLengthSource.next(gift.totalCount);
this.articleCommentSubject.next(data);
});
}
connect(): Observable<any[] | readonly any[]> {
return this.articleCommentSubject.asObservable();
}
disconnect(): void {
this.articleCommentSubject.complete();
this.loadingSubject.complete();
}
}
这是我的html:
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
<!-- Position Column -->
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef mat-sort-header> No. </th>
<td mat-cell *matCellDef="let element"> {{element.position}} </td>
</ng-container>
</table>
这是我的`ts文件:
dataSource: ArticleCommentDataSource;
@ViewChild(MatSort, {static: true}) sort: MatSort;
我的DataSource
没有sort
属性。
如何在表格中放置可排序内容????