简体   繁体   English

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

[英]GWT Determining Row Value during Cell render

I'd like to determine whether an icon is used based on the value of the "row" value that is in the CellTable (or DataGrid). 我想根据CellTable(或DataGrid)中“行”值的值来确定是否使用了图标。 How do I determine that when building the Cell renderer? 构建单元格渲染器时如何确定?

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.
  }
};

If you need the row object, you'll have to use an IconCellDecorator<RowObject> , and wrap or subclass the ClickableTextCell to extract the String out of the RowObject . 如果需要对象,则必须使用IconCellDecorator<RowObject> ,并包装ClickableTextCell或将其子类化,以从RowObject提取String

Or you could use a CompositeCell and ImageResourceCell instead of the IconCellDecorator . 或者,您可以使用CompositeCellImageResourceCell代替IconCellDecorator

I decided to rewrite IconCellDecorator so that the getImageUsed method passes in the Context object, which gives me the row index and key. 我决定重写IconCellDecorator,以便getImageUsed方法传入Context对象,这为我提供了行索引和键。 This seemed the most straightforward for specifically what I was trying to accomplish, although Thomas' answer should work as well. 对于我要完成的任务,这似乎是最直接的方法,尽管Thomas的回答也应该起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM