我正在尝试在单个网格单元格中创建一个包含多个图像的列。 以下是列配置
private ColumnConfig<SensorTreeModel,ImageResource> actionsCol;
actionsCol = new ColumnConfig<SensorTreeModel,ImageResource>(new ValueProvider<SensorTreeModel, ImageResource>() {
com.sencha.project.client.Resources resources = GWT.create(com.sencha.project.client.Resources.class);
@Override
public ImageResource getValue(SensorTreeModel object) {
ImageResource add = com.sencha.project.client.Resources.INSTANCES.add();
return add;
}
@Override
public void setValue(SensorTreeModel object, ImageResource value) {
if (object.getIsLeaf()) {
}
}
@Override
public String getPath() {
return "actions";
}
});
actionsCol.setHeader("");
//This is where an error occurs
actionsCol.setCell(compositeCell);
我的每个图像单元格如下所示:
public class ImageCell implements HasCell<SensorTreeModel, ImageResource>{
private ImageResourceCell imageCell = new ImageResourceCell();
@Override
public Cell<ImageResource> getCell() {
// TODO Auto-generated method stub
return imageCell;
}
@Override
public FieldUpdater<SensorTreeModel, ImageResource> getFieldUpdater() {
// TODO Auto-generated method stub
return new FieldUpdater<SensorTreeModel, ImageResource>() {
@Override
public void update(int index, SensorTreeModel object, ImageResource value) {
//object.setLast(ImageResource(value));
}
};
}
@Override
public ImageResource getValue(SensorTreeModel object) {
// TODO Auto-generated method stub
return com.sencha.project.client.Resources.INSTANCES.add();
}
}
复合单元格如下所示:
List<HasCell<SensorTreeModel, ?>> cells= new ArrayList<HasCell<SensorTreeModel,?>>();
cells.add(new com.sencha.project.client.ImageCell());
cells.add(new com.sencha.project.client.ImageCell());
CompositeCell<SensorTreeModel> compositeCell = new CompositeCell<SensorTreeModel>(cells);
所以,我想要做的是在网格单元格中创建许多图像。我最初创建一个返回图像的ImageCell。现在,我将这些细胞的数量添加到复合细胞上。后来我从actionsCol(列配置)中的setCell函数引用了这个复合单元格。