【问题标题】:how to reset ag-grid infinite scroll如何重置ag-grid无限滚动
【发布时间】:2019-04-29 22:02:28
【问题描述】:

我目前正在使用 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 重置网格并删除当前数据并重新开始加载数据?以便将带有过滤器的新数据加载到网格上。

【问题讨论】:

    标签: angular ag-grid-angular


    【解决方案1】:

    如果您正在使用:

    rowModelType={'serverSide'}
    

    清除数据:

    api.purgeServerSideCache(null)
    

    【讨论】:

      猜你喜欢
      • 2020-11-05
      • 2020-04-07
      • 2019-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 2019-08-28
      • 1970-01-01
      相关资源
      最近更新 更多