angular - 如何重置ag-grid无限滚动
问题描述
我目前正在使用 rowModelType:'infinite' 实现 ag-grid,并在用户向下滚动到列表时加载数据。用户有时必须过滤 100 万条记录,我们有每个用户存储的外部过滤器。
这些外部过滤器被发送到后端以仅获取用户需要查看的记录。当用户选择这些过滤器时,我需要通过重置页数并返回以获取过滤记录来使用新数据重新加载网格,目前,我在 HTTP 请求中传递过滤器。
我当前的代码如下所示。
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)
推荐阅读
- c# - Unity 2D - 通过类变量的值从类列表中获取值
- c# - ConcurrentDictionary GetOrAdd 异步
- android - 限制 Firebase 实时数据库中的用户数
- java - SOLR中使用“fq”参数时如何限制“候选”文档的数量
- dialogflow-es-fulfillment - 无法在 Dialogflow Fulfillment 中跨意图传递数据
- azure - 如何使用 Lucee 的 azure 存储
- c++ - C++ vector::clear() - 破坏顺序?
- python - 在 Python 中使用牛顿法,没有错误消息但不打印/绘图
- python-3.x - 如何将 pylint 选项卡宽度从 4 个空格更改为 2 个空格?
- html - html中的某些字符只出现在chrome中而不出现在其他浏览器中