Dynamic styles for GWT cellTable cells

爱⌒轻易说出口 提交于 2019-12-03 18:15:56

问题


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

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.


回答1:


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.

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, you can then extend IdentityColumn as the getValue then becomes trivial.



来源:https://stackoverflow.com/questions/13361648/dynamic-styles-for-gwt-celltable-cells

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