How to add an image as a background for the cell in the GXT 2.2 Grid

穿精又带淫゛_ 提交于 2019-12-11 16:19:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!