英文:
How to get number of Grid rows before applied filter
问题
我有一个应用了列过滤器的表格(Grid)。在刚刚填充数据后,我调用Grid.getListDataView().getItemCount()可以获得正确的数量。但是,如果我在刷新后再次调用它,得到的数量是过滤器应用后的数量。例如,如果表格应用了过滤器,显示了5条可见记录(同时隐藏了10条记录),getItemCount()方法返回15。但是在刷新表格后,这个数量会变成5 - 这是过滤器应用后可见记录的数量,而不是预期的15。
我如何在列过滤器应用之前获取表格中项目的数量?
英文:
I have a Grid with column filters applied. After calling Grid.getListDataView().getItemCount() immediately after population, I get the correct number. However, if I call it again after a refresh, the number I get is after the filter has been applied. For example, if the Grid is presented with filters applied and displays 5 visible records (while hiding 10 records), the getItemCount() method returns 15. But upon refreshing the Grid, the number changes to 5 - which is the number of visible records after the filter has been applied, not the expected 15.
How can I retrieve the number of items in the Grid before the column filters have been applied?
答案1
得分: 1
这是该方法的预期行为,您可以通过阅读其JavaDoc来了解这一点。
/**
* 如果已设置任何过滤器,请获取带有**过滤器**的完整项目计数。由于项目计数可能在任何时候更改,建议使用{@link #addItemCountChangeListener(ComponentEventListener)}方法添加侦听器,以在项目计数发生更改时收到通知。
*
* @return 过滤后的项目计数
* @see #addItemCountChangeListener(ComponentEventListener)
*/
希望这对您有帮助。
英文:
This is intended behavior of the method, you can see this by reading its JavaDoc.
/**
* Get the full item count **with filters** if any set. As the item count might
* change at any point, it is recommended to add a listener with the
* {@link #addItemCountChangeListener(ComponentEventListener)} method
* instead to get notified when the item count has changed.
*
* @return filtered item count
* @see #addItemCountChangeListener(ComponentEventListener)
*/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论