简体   繁体   中英

how to reset ag-grid infinite scroll

I am currently implementing the ag-grid with the rowModelType:'infinite' and the data loads when the user scrolls down to the list. The user will have to filter 1 million records at times and we have external filters that are stored per user.

These external filters are sent to the backend to get only the records that user need to see. when a user selects those filters I need to reload the grid with the new data by resetting the page count and going back to get filtered records, currently, I am passing filters in the HTTP request.

My current code looks like below.

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);
        });
    }
};

How can I tell ag-grid to reset the grid and remove the current data and start loading the data again? so that the new data with filters can be loaded on the grid.

If you're using:

rowModelType={'serverSide'}

Purge data:

api.purgeServerSideCache(null)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM