this.gridApi.refreshInfiniteCache()未清除selectedRows [英] this.gridApi.refreshInfiniteCache() is not clearing selectedRows

查看:278
本文介绍了this.gridApi.refreshInfiniteCache()未清除selectedRows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用无限行模型,当我从网格中删除选定的行时,我正在调用刷新缓存,因此可以说我删除了选定的 id = 1
但在之后refreshInfiniteCache();新行通过 getRows()来自数据库,其 id = 2 ,并且所选行不会取消选择自动,如果我再次单击删除按钮,那么我在selectedData中获得两行。这是为什么?从 this.gridApi.getSelectedRows() getSelectedNodes()中,我得到两行,前一行ID = 1,下一行是ID = 2的删除操作。应该只获得一行id = 2而不是id = 1我已经删除了这一行并刷新了缓存。请告诉我我缺少什么吗?

I am using Infinite Row Model and when i deleted the selected row from Grid then i am calling refreshing cache so lets say i deleted the selected id = 1 but after refreshInfiniteCache(); new row comes from DB via getRows() its id = 2 and that selected row does not get un-select auto and if i am clicking on delete button again then I am getting two rows in selectedData. Why is that? from this.gridApi.getSelectedRows() and getSelectedNodes() i am getting two rows previous row id = 1 and next row which came after delete that is id = 2. I should get only one row id = 2 not id = 1 again i have deleted this row and refreshed cache. Please tell me am i missing something?

deleteRow() {
const selectedData = this.gridApi.getSelectedRows();
this.assetTypeService.deleteAssetType(selectedData[0].AssetTypeID)
  .subscribe((result) => {
    this.gridApi.refreshInfiniteCache();
  })
}


推荐答案


refreshInfiniteCache( ) :将缓存中当前所有已加载的块标记为要重新加载。如果缓存中有10个块,则所有10个块都将标记为重新加载。 旧数据将一直显示,直到加载新数据为止。

refreshInfiniteCache() : Marks all the currently loaded blocks in the cache for reload. If you have 10 blocks in the cache, all 10 will be marked for reloading. The old data will continue to be displayed until the new data is loaded.

因此您可以致电 refreshInfiniteCache(),如果您将通过 setRowData(rows)

So you can call refreshInfiniteCache() if you will replace all grid data via setRowData(rows)


setRowData(rows) 将新行设置到网格中。

setRowData(rows) Set new rows into the grid.

或者您需要更新网格数据完成删除请求后。

or you need to update the grid data after completing a delete request.

params.api.updateRowData({remove:[...array of data-objects to remove...]});

这篇关于this.gridApi.refreshInfiniteCache()未清除selectedRows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆