众所周知,在infinite
rowModelType
中,我们必须为ag-grid设置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
函数中知道吗?