使用ag-grid dataSurce时,如何知道是否由于滚动或过滤而调用了getRows函数

时间:2018-06-08 06:34:11

标签: ag-grid ag-grid-ng2

众所周知,在infinite rowModelType中,我们必须为设置dataSource

const dataSource = {
  rowCount: count
  getRows: (params: IGetRowsParams) => this.getRows(params, [])
};
this.gridApi.setDatasource(dataSource);

现在,只要需要获取网格中的行(由于滚动) OR ,就会调用dataSource.getRows方法。 / p>

我需要根据这个原因决定需要进行多少次ajax调用。下面的代码块解释了这一点。

private getRows(params: IGetRowsParams, data: any) {
    // two ajax calls can be made from here
    // 1. getCount
    // 2. getData

    //  if this getRows function is called due to scrolling in the grid,
    //     I just want to call getData - no need to call getCount as I already know it
    //  if this is called due to change in filter,
    //     I need to call getCount as well as the no of rows will be different

    // How can I know here due to which above mentioned reasons, getRows is getting called?
}

无论如何在getRows函数中知道吗?

0 个答案:

没有答案