【问题标题】:AG Grid Pagination with Infinite Scrolling具有无限滚动的 AG 网格分页
【发布时间】:2018-08-02 12:47:08
【问题描述】:

我在 Angular 4 上实现了 ag-grid,并且遇到了服务器端分页问题。

在实现无限滚动分页时,有没有办法在网格就绪事件上转到特定页面?

【问题讨论】:

  • 你的意思是说你想到达特定的滚动位置。我说的对吗?

标签: angular ag-grid ag-grid-ng2


【解决方案1】:

当您说具有无限滚动的特定页面时,我假设您想要到达特定滚动位置。

假设您一次从服务器获取 20 条记录(您的 getRows 方法也在获取相同数量的记录),并且您想在加载网格时 50th 记录。

按照以下步骤操作。

// #1  initialize grid with empty array, getRows will fetch the records
let dataSource = {
  rowCount: null,
  getRows: (params: IGetRowsParams) => this.getRows(params, [])
};
this.gridApi.setDatasource(dataSource);


// #2.
private getRows(params: IGetRowsParams, data: any) {
    this.yourSvc.getRows(serverParams, params.startRow)
        .subscribe((result: any[]) => {

             params.successCallback(result, null);

             // #3. keep a flag just to make sure its done for the first time only
             if(this.isFirstTime) {
                this.gridApi.ensureColumnVisible(0);
                this.gridApi.ensureIndexVisible(50);
                this.gridApi.setFocusedCell(50, 0, null);

                this.isFirstLoad = false;
             }
        });
}

【讨论】:

    猜你喜欢
    • 2019-04-21
    • 2022-06-11
    • 1970-01-01
    • 2020-11-05
    • 2018-11-17
    • 2017-07-06
    • 1970-01-01
    • 2016-02-20
    • 2021-01-26
    相关资源
    最近更新 更多