GWT cellTable单元格的动态样式 [英] Dynamic styles for GWT cellTable cells

查看:111
本文介绍了GWT cellTable单元格的动态样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用GWT时遇到问题。我正在构建一个cellTable的列,我想要一个单元格的样式取决于该单元格的值:

I'm having an issue using GWT. I'm building the columns of a cellTable and I want the style of a cell to depends of the value of that cell:

Column<MyProxy, MyProxy> editButtonColumn = new Column<MyProxy, MyProxy>(new ActionCell<MyProxy>("", new ActionCell.Delegate<MyProxy>() {
        @Override
        public void execute(MyProxy record) {
            if (object.isEditable()) {
                doSomething(record);
            }
        }
    })) {
        @Override
        public MyProxy getValue(MyProxy object) {
            if (object.isEditable()) {
                this.setCellStyleNames("editButtonCell");
            }
            return object;
        }
    };

我已经在调试模式下检查了样式editButtonCell但是在HTML生成的时候,风格每次都缺少FIRST ROW ...它看起来像一个GWT错误,但也许你们有更好的解释。

I've checked in debug mode the style "editButtonCell" is applied correctly. But in the HTML generated, the style is missing everytime for the FIRST ROW... It looks like a GWT bug, but maybe you folks have a better explanation.

推荐答案

我没有检查,但很可能单元格的打开已经生成的时间 getValue 被调用,因此 setCellStyleNames 将只适用于列中剩余的单元格。

I haven't checked but most probably the opening of the cell has already been generated by the time getValue is called, so setCellStyleNames will only apply to the remaining cells in the column.

正确的方法是覆盖 getCellStyleNames 返回CSS类名称或不根据单元格值

The right way to do it is to override getCellStyleNames of the column to return the CSS class name or not depending on the cell value.

BTW,您可以将 IdentityColumn code> getValue 然后变得无关紧要。

BTW, you can then extend IdentityColumn as the getValue then becomes trivial.

这篇关于GWT cellTable单元格的动态样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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