Angular MatPaginator 和 Azure 表存储

标签 angular angular-material azure-table-storage azure-tablequery mat-pagination

我正在尝试实现一个带有分页的 Angular Material 表,该表连接到后端,从 Azure 表存储检索数据。

我知道,表存储支持ExecuteQuerySegmentedAsync ,返回 TableContinuationToken 。看起来不错。所以在前端,我得到这样的东西:

interface IPagedResult<T> {
    items: T[];
    isFinalPage: boolean;
    continuationToken: string;
}

interface ILog {
    enqueuedDate: string;
    ...
}

component.ts 中的某处:


private logsTableSource: MatTableDataSource<ILog>;
@ViewChild(MatPaginator)paginator: MatPaginator;

ngAfterViewInit() {
   myService.GetRecords(this.paginator.pageSize)
            .subscribe(
               (res: IPagedResult<ILog>) => {
                    this.logsTableSource = new MatTableDataSource<ILog>(res.items);
               });
}

现在我想知道如何获取页数?并让服务器知道我想要什么具体页面?

continuationToken 如下所示: enter image description here

事实上,我可以用这个 continuationToken 做什么?

为了更好地理解,表格如下所示: enter image description here

最佳答案

您链接到的 TableContinuationToken 文档还指出:

A method that may return a partial set of results via a TableResultSegment object also returns a continuation token, which can be used in a subsequent call to return the next set of available results.

这意味着 token 可用于获取下一组可用结果,您不能将它们用作分页索引。无法为结果的第 7 页制作 TableContinuationToken。

关于Angular MatPaginator 和 Azure 表存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65790134/

相关文章:

angularjs - md-checkbox 不适用于 ng-click

javascript - Angular Material 6 Mat-Chip-List - 两个 mat-chip-list 声明共享相同的数据源

azure - 升级到 Azure 存储后丢失的方法

c# - 如果 Azure 表存储服务上下文遇到一个错误,它会继续抛出相同的错误

javascript - Angular 中的异步操作完成

ios - 拒绝连接数据:text/html;charset=utf8 in iOS Safari

angularjs - Angular 重复、跨列突破

azure - Azure 表存储支持亚洲语言吗?

angular - 同时使用 ngFor 和 ngIf 列出项目

css - 如何设置工具提示的样式?