且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在GXT 2.2网格中为单元格添加图像作为背景

更新时间:2023-01-25 20:12:48

如果要在列中呈现按钮,请参见ColumnConfigsetRenderer方法.

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;
    }
}):