可分类的角物料台

时间:2020-04-27 07:38:20

标签: javascript angular typescript

我有一个有角度的材料表。我想在表中添加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属性。

如何在表格中放置可排序内容????

0 个答案:

没有答案