问题
I am trying to create a column with multiple images in a single grid cell. The following is the column config
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);
Each of my image cell looks like below:
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();
}
}
The composite cell looks like below:
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);
So, what I am trying to do is create a number of images in a grid cell. I initially create an ImageCell which returns an image. Now, I add number of these cells onto the composite cell. Later I reference this composite cell from the setCell function in actionsCol (column config).
来源:https://stackoverflow.com/questions/36127646/gxt-3-columnconfig-setcell-not-working-for-compositecell