GWT在单元渲染期间确定行值

GWT在单元渲染期间确定行值,gwt,datagrid,render,cell,celltable,Gwt,Datagrid,Render,Cell,Celltable,我想根据CellTable(或DataGrid)中的“行”值确定是否使用图标。在构建单元渲染器时,如何确定这一点 IconCellDecorator<String> icd = new IconCellDecorator<String>(res.search(), new ClickableTextCell()) { @Override protected boolean isIconUsed(String value) { //value may not

我想根据CellTable(或DataGrid)中的“行”值确定是否使用图标。在构建单元渲染器时,如何确定这一点

IconCellDecorator<String> icd = new IconCellDecorator<String>(res.search(), new ClickableTextCell()) {
  @Override
  protected boolean isIconUsed(String value) {
    //value may not be unique across rows (column value), I really need the row instance here.
  }
};
IconCellDecorator icd=新的IconCellDecorator(res.search(),new ClickableTextCell()){
@凌驾
已使用受保护的布尔值(字符串值){
//值在行之间可能不是唯一的(列值),我确实需要这里的行实例。
}
};
如果需要行对象,则必须使用
IconCellDecorator
,将
ClickableTextCell
包装或子类化,以从
行对象中提取
字符串


或者您可以使用
CompositeCell
ImageResourceCell
而不是
IconCellDecorator
我决定重写IconCellDecorator,以便getImageUsed方法在上下文对象中传递,上下文对象为我提供行索引和键。虽然Thomas的答案也应该适用,但这似乎是我试图实现的最直接的目标。

我似乎真的希望装饰程序采用我的行类型,但是ClickableTextCell不知道如何获取它所需的字符串值。似乎我必须编写一个自定义IconCellDecorator,但我认为可能有一个更干净的解决方案。。。考虑到这可能会有所帮助。包装/子类化ClickableTextCell看起来是个棘手的部分。它不是真正用来处理非文本的。我会看看CompositeCell是否有意义。(事实上,我已经制作了自己的图标编辑器,当图标未被使用时,它不会显示空白区域。因此可能需要重构)