0

我想将按钮添加到单元格,但现在我准备为单元格的背景设置图像,然后处理点击。如何将图像添加到单元格?

4

2 回答 2

2

如果要在列中呈现按钮,请参见setRenderer的方法ColumnConfig

以下将在网格的每一行上设置一个按钮:

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;
    }
}):
于 2013-06-19T14:26:45.447 回答
1

无需手动添加已有ButtonCell。

只是利用它。

您甚至可以通过setIcon() 方法向其添加图标

于 2013-06-19T12:39:45.133 回答