reset cache in infinitePageRowModel in ag grid community v22

1.3k Views Asked by At

Using 'infinite' rowModel in ag -grid. I have implemented Pagination.

  <select [(ngModel)]="pageSizeSelected" (change)="onPaginationChanged($event)">
        <option value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
        <option value="40">40</option>
    </select>
<ag-grid-angular
    #myGrid
    class="ag-theme-balham"
    [columnDefs]="columnDefs"
    [gridOptions]="gridOptions"
    [cacheOverflowSize]="cacheOverflowSize"
    [maxConcurrentDatasourceRequests]="maxConcurrentDatasourceRequests"
    [infiniteInitialRowCount]="infiniteInitialRowCount"
    [pagination]=true
    (gridReady)="onGridReady($event)">
</ag-grid-angular>

On First time loading the PageSize is set 10 and CacheBlockSize is set 10 then startRow = 0 and endrow = 10. But user can use the dropdown to change the page size to 15 I have to change the IGetRowParams

onPaginationChanged(event){
this.gridOption.cacheBlockSize = pageSizeSelected;
this.gridOption.paginationSetPageSize(pageSizeSelected);

After, setting the both the gridoption I can see that in Quick Watch they have been set but the inifitePageRowModel.cacheParams still has previous selected which is 10. So ** how can I reset the cache params so that Start Row - 0 and End Row - 15 is reset accordingly**

But how can I achieve this. I have tried -

purgeInfiniteCache - it clear the whole data and make a new call but this doesn't set my IGetRowParams as expected

refreshInfiniteCache - it internally calls refresh cache not resetCache

Please, do anyone have idea how can I resetCahce in infinitePageRowModel .

1

There are 1 best solutions below

0
On

Please refer to https://github.com/ag-grid/ag-grid/issues/2202

onGridPageSizeChanged(size: number): void {
        this.gridOptions.cacheBlockSize = size;
//// this is a way to use private fields in typescript
        const api: any = this.gridOptions.api;
        api.infinitePageRowModel.resetCache();
        this.gridOptions.paginationPageSize = size;

}