<分区>
Possible Duplicate:
GWT Table that supports dynamic filtering
我一直在搜索 SO 和文档,但没有成功。
是否已经实现了某种过滤 GWT (2.3) CellTable 的机制?我所说的过滤是指“仅显示满足此条件的那些数据”。
<分区>
Possible Duplicate:
GWT Table that supports dynamic filtering
我一直在搜索 SO 和文档,但没有成功。
是否已经实现了某种过滤 GWT (2.3) CellTable 的机制?我所说的过滤是指“仅显示满足此条件的那些数据”。
最佳答案
Google Guava library R09 有静态 Collection2.filter(..)
方法。该库也已扩展到可以在 GWT 应用程序中使用。过滤 Collection<MyType>
的实例在将其提供给您的 CellTable 之前,您可以编写类似于以下内容的内容:
List<MyType> filteredList =
new ArrayList<MyType>(Collections2.filter(unfilteredList,
new Predicate<MyType>() {
@Override
public boolean apply(MyType listItem) {
return (filterCondition) ? true : false;
}
}));
现在filteredList
可以提供给您的 CellTable:
myCellTable.setRowCount(filteredList.size(), true);
myCellTable.setRowData(0, filteredList);
同时使用库 guava-r09.jar
和 guava-r09-gwt.jar
需要添加到 GWT 项目的类路径中。
关于java - GWT:如何在 CellTable 上实现过滤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6361412/