Java GWT在DataGrid中隐藏分组数据
我们正在使用GWT。我有一个DataGrid,在左边的列中有许多重复的值。我想把这些藏起来。例如: 我有:Java GWT在DataGrid中隐藏分组数据,java,gwt,Java,Gwt,我们正在使用GWT。我有一个DataGrid,在左边的列中有许多重复的值。我想把这些藏起来。例如: 我有: Town | Address | Color ------------------------------------------ Springfield | Springfield Heights | Blue Springfield | Bum town | Red Springfield | Little Italy
Town | Address | Color
------------------------------------------
Springfield | Springfield Heights | Blue
Springfield | Bum town | Red
Springfield | Little Italy | Blue
Shelbyville | Manhattan Square | Green
Shelbyville | Chinatown | Red
我希望:
Town | Address | Color
------------------------------------------
Springfield | Springfield Heights | Blue
| Bum town | Red
| Little Italy | Blue
Shelbyville | Manhattan Square | Green
| Chinatown | Red
我尝试了一些方法,但它们不能很好地处理可排序列。有没有标准的方法可以做到这一点 您可以为用于Town列的单元格重写
GetCellStyleName
。此方法为您提供上下文,您可以使用上下文查看此单元格在列中的位置(Context.getIndex()
)。使用此信息,可以将此单元格中的值与其上方单元格中的值(如果有)进行比较。如果相同,则返回样式以隐藏此单元格中的值
请注意,如果在为单元格重写getValue
时仅返回空值,则该函数将不起作用,因为它将使下一个单元格显示其值,即使其值相同。当然,您可以通过查找直到找到一个非空单元格来解决这个问题,但是覆盖getCellStyleNames
并简单地隐藏重复值看起来更简单
因为这是您的计算单元中的一种方法,所以它在更新、列排序等方面应该表现良好。谢谢,这让我走上了正确的轨道。GetCellStyleName在列中,而不是在单元格中,但我现在有一些东西正在工作。