Angular 如何重置ag栅格无限滚动
我目前正在使用rowModelType:“infinite”实现ag网格,当用户向下滚动到列表时加载数据。用户有时需要过滤100万条记录,我们有每个用户存储的外部过滤器 这些外部过滤器被发送到后端,以仅获取用户需要查看的记录。当用户选择这些过滤器时,我需要通过重置页面计数并返回以获取过滤记录来重新加载网格中的新数据,目前,我正在HTTP请求中传递过滤器 我当前的代码如下所示Angular 如何重置ag栅格无限滚动,angular,ag-grid-angular,Angular,Ag Grid Angular,我目前正在使用rowModelType:“infinite”实现ag网格,当用户向下滚动到列表时加载数据。用户有时需要过滤100万条记录,我们有每个用户存储的外部过滤器 这些外部过滤器被发送到后端,以仅获取用户需要查看的记录。当用户选择这些过滤器时,我需要通过重置页面计数并返回以获取过滤记录来重新加载网格中的新数据,目前,我正在HTTP请求中传递过滤器 我当前的代码如下所示 var datasource = { rowCount: null, getRows: function
var datasource = {
rowCount: null,
getRows: function (params) {
console.log("asking for " + params.startRow + " to " + params.endRow);
that.service.loadDataViaSubscription(that.getActiveFilter())
.map((response: Response) => {
console.log("Mapping the data from api.");
return <any>response.json();
})
.subscribe(
data => {
setTimeout(function () {
var rowsThisPage = data[0];
that.currentRecordCount = params.endRow;
if (params.startRow === 0) {
that.currentRecordCount = rowsThisPage.length < 100 ? 100 : rowsThisPage.length;
}
else {
that.currentRecordCount = params.startRow + rowsThisPage.length;
}
params.successCallback(rowsThisPage, that.currentRecordCount);
that.agGridOptions.api.hideOverlay();
}, 500);
});
}
};
如何让ag grid重置网格并删除当前数据,然后重新开始加载数据?这样,带有过滤器的新数据可以加载到网格上。如果您使用:
rowModelType={'serverSide'}
清除数据:
api.purgeServerSideCache(null)