ag-grid - 删除具有无限行模型的行 [英] ag-grid - Remove row with infinite row model

查看:65
本文介绍了ag-grid - 删除具有无限行模型的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用具有无限行模型和分页功能的网格来删除一行.我不确定如何删除特定行并更新内部模型而不必刷新网格(从而发出新的 ajax 请求).

I'm trying to delete a row using a grid with Infinite Row model and a Pagination feature. I'm not sure how to delete a specific row and update the internal model without having to refresh the grid (thus making a new ajax request).

我已经读过这个帖子:https://github.com/ag-grid/ag-grid/issues/193

显然我应该删除服务器上的行(我已经在做),然后调用刷新 api 但这会导致每次调用getRows"函数和分页,另一个问题是分页不会更新.如果我在 10 个页面中有 100 个项目,我删除一个项目并调用刷新缓存 api,内部分页不会更新,保留 100 个项目总数和 10 个页面作为参考.

and apparentely I should delete the row on the server (which I'm already doing) and then call the refresh api but this cause to have the "getRows" function to be called every time and the pagination and, another issue is that the pagination doesn't update. If I have 100 items in 10 pages, I delete one item and call the refresh cache api, the internal pagination is not updated keeping the 100 items total and 10 pages as reference.

推荐答案

我应该删除服务器上的行(我已经在做),然后调用刷新 api 但这会导致getRows"每次调用的函数和分页,另一个问题是分页不更新.

I should delete the row on the server (which I'm already doing) and then call the refresh api but this cause to have the "getRows" function to be called every time and the pagination and, another issue is that the pagination doesn't update.

对于无限滚动,我们只需要注意计数而不是分页.可以通过以下步骤实现.

As per infinite scrolling, we just need to take care about count instead of pagination. Which can be achieved as below steps.

  1. 在您的 getRows 函数中,调用服务器以获取记录数量以及数据.
  2. 使用结果更新计数.这将相应地更新滚动条大小.
  1. In your getRows function, call server to fetch numbers of records as well along with the data.
  2. Use the result to update the count. Which will update the scrollbar size accordingly.

检查下面的代码.

private getRows(params: IGetRowsParams, data: any) {
   Observable.forkJoin(
   [
      this.dataSvc.getResult(serverParams, params.startRow),
      this.dataSvc.getCount(serverParams)
   ])
   .subscribe((result: any[]) => {
      params.successCallback(result[0], <number>result[1]);
   })
}

注意:这个答案是基于 无限滚动推荐给出的 团队.

Caution: This answer is given based on infinite scrolling recommendation given by ag-grid team.

在 v9.0 中,ag-Grid 分页从服务器端分页更改为客户端分页.然后在 v10.1 中删除了服务器端分页.

In v9.0 ag-Grid pagination changed from server side pagination to client side pagination. Server side pagination was then removed in v10.1.

如果您在进行服务器端分页,我们建议您改用无限滚动分页作为迁移到新机制的一种方式.

If you were doing server side pagination, we recommend moving to pagination with infinite scrolling as a way of migration to the new mechanism.

如果您手动切片数据源中的数据以模拟仅在浏览器中完成的分页,我们建议您使用默认的内存行模型并将行数据设置为正常,然后设置网格属性 pagination=true.

If you were slicing manually the data in your Datasource to mimic pagination done in the browser only, we recommend that you use the default In Memory Row Model and set the row data as normal and then set grid property pagination=true.

如果您打算使用建议的最后一点,那么我猜getRows 问题根本不会发生.

If you are going to use the last point suggested, then I guess getRows issue will not occur at all.

这篇关于ag-grid - 删除具有无限行模型的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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