How to get filtered rows in ag-grid?

感情迁移 提交于 2020-07-20 07:02:53

问题


I have an ag-Grid with filtering option.

How to get the filtered rows (not the selected) in ag-Grid?


回答1:


You can use the forEachNodeAfterFilter(callback) api method for this.

See https://www.ag-grid.com/javascript-grid-api for all available API calls, including the various forEachXXX methods.




回答2:


This took me forever so I'm posting here. Use onFilterChanged() to access the filtered rows, or the filtered + selected rows. The event passed to onFilterChanged() can be used like so (example in Typescript React)

onFilterChanged = ev => {
  if (ev?.api?.rowModel?.rowsToDisplay) {
    this.setState({ selectedRows: ev?.api?.rowModel?.rowsToDisplay.filter(node => node.isSelected()) });
  }
};


来源:https://stackoverflow.com/questions/43542110/how-to-get-filtered-rows-in-ag-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!