Pau*_*aul 3 reactjs ag-grid ag-grid-react
Ag-Grid提供了该方法。ensureIndexVisible(index, 'middle');使用该方法,可以轻松滚动到选定的索引。但是,如何从用户那里获得滚动位置的最新已知索引?
例如:我们有一个包含600行的表。用户正在滚动-更新发生。桌子变了一点。现在,我的行为是表格滚动到顶部。用户现在必须再次滚动到他的最后位置。
我想将用户重定向到历史上一个滚动位置: ensureIndexVidisble(USERS_LAST_KNOWN_SCROLLING_POSITION, 'middle');
除信息外:用户不在表中工作。因此,我无法保存他在行中的最后单击。
我该如何实现?
小智 6
感谢一百万,为了给大家腾出一些时间,以下是您必须传递给属性 [gridOptions] 的内容。只要您的数据具有唯一的 ID,您就已设置完毕。
// gridOptions
{
...,
deltaRowDataMode: true,
getRowNodeId: function (data) {
return data.id;
},
},
Run Code Online (Sandbox Code Playgroud)
他们以典型的AG方式将这些重要信息隐藏在文档中:
方法3-增量行数据增量方法正在使用上面的行数据方法,但是具有deltaRowDataMode = true属性。
启用deltaRowDataMode时,网格将比较新行数据和当前行数据,并为您创建一个事务对象。然后,网格将更改作为更新事务执行,并保留所有网格选择,过滤器等。
如果要管理网格外部的数据(例如,在Redux存储中),请使用此选项,然后让网格确定需要进行哪些更改才能使网格的数据版本保持最新。
https://www.ag-grid.com/javascript-grid-data-update/#bulk-updating
This in my opinion should be a setting you always use if your rows have a unique ID (I hope they do, it's good practice to do it). SetdeltaRowDataMode to true and use getRowNodeId to specify a unique id for the row.
After that your grid will update much more efficiently (only updating what is needed) and it won't jump to the top when it does as it's not re-creating every row and cell in the grid on an update.
For good measure you could also add the suppressScrollOnNewData option, though I'm not sure if it's needed if you do the above.
| 归档时间: |
|
| 查看次数: |
766 次 |
| 最近记录: |