问题
I wanted to add the button to the cell but now I'm ready just to set an image for the background of the cell and than handle the click. how to add the image to the cell?
回答1:
If you want to render a button in a column, see setRenderer
method of ColumnConfig
.
The following will set a button on each row of the grid:
ColumnConfig cfg = new ColumnConfig();
cfg.setRenderer(new GridCellRenderer() {
@Override
public Object render(M model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<M> store, Grid<M> grid) {
Button button = new Button();
// set up button based on params to this render function
// for example, the `model` argument is the item backing each row.
// this render method is called for each row in the grid
// see http://dev.sencha.com/deploy/gxt-2.2.5/docs/api/com/extjs/gxt/ui/client/widget/grid/GridCellRenderer.html
return button;
}
}):
回答2:
No need to add manually There is already a ButtonCell.
Just make use of it.
And you can Add icon to it even by setIcon() method.
来源:https://stackoverflow.com/questions/17191324/how-to-add-an-image-as-a-background-for-the-cell-in-the-gxt-2-2-grid