如何在GXT 2.2网格中为单元格添加图像作为背景 [英] How to add an image as a background for the cell in the GXT 2.2 Grid

查看:74
本文介绍了如何在GXT 2.2网格中为单元格添加图像作为背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

如果要在列中呈现按钮,请参见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;
    }
}):

这篇关于如何在GXT 2.2网格中为单元格添加图像作为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆