【发布时间】:2019-11-04 07:55:09
【问题描述】:
我希望使用 ag-grid 的“服务器端”模式重新获取每个页面的数据。 为了做到这一点,我使 maxBlocksInCache 1 和 cacheBlockSize 等于每页的项目。直到这里它工作正常。
现在,当我更改每页的项目数时,网格开始通过获取数据在自身上循环。 我假设这是因为 cacheBlockSize 不可更改或在重新获取行(永远不会完成)之后发生更改。
现在我尝试将缓存作为输入而不是 agGridOption,但它什么也没改变。
<select #paginationSelect (change)="onPageSizeChanged(paginationSelect.value)" [(ngModel)]="itemsPerPage">
<option [value]="item">2</option>
<option [value]="item">10</option>
</select>
<ag-grid-angular
[gridOptions]="gridOptions"
[cacheBlockSize]="itemsPerPage"
style="width: 100%; height: 250px;">
</ag-grid-angular>
this.gridOptions = {
...
rowModelType: 'serverSide',
pagination: true,
paginationPageSize: this.itemsPerPage, // itemsPerPage is a class attribute attached to a select element using ngModel.
maxBlocksInCache: 1,
...
}
// function called on change of select element value representing the number of items to display per page
onPageSizeChanged(newPageSize) {
this.gridApi.paginationSetPageSize(newPageSize);
}
我希望能够动态更改页面项目的大小,同时保持在页面更改时重新获取数据。
【问题讨论】:
-
你在哪里知道这是怎么做到的?我遇到了类似的情况
-
非常感谢您分享信息。我遇到了同样的问题。
标签: angular typescript pagination server-side ag-grid-angular