智能GWT列表网格 - 在记录点击时将hilite设置为列表网格

时间:2015-11-23 04:47:56

标签: gwt smartgwt listgrid

我正在尝试在列表网格的记录点击处理程序中设置一个hilite。我已经厌倦了以下代码,

我的hilites如下,

 public static Hilite[] getWayBillSetHilites() {
        return new Hilite[]{
                new Hilite() {
                    {
                        setFieldNames("RECORD_VIEWED_STATUS");
                        setCriteria(new Criterion("RECORD_VIEWED_STATUS", OperatorId.EQUALS, "TRUE"));
                        setCssText(Constant.Css.TEXT_ITALIC_GRAY_32);
                        setTextColor("font-style:italic;color:#525252;");
                        setId("0");
                    }
                }
        };
    }

记录网格的点击处理程序如下所示,

     grid.addRecordClickHandler(new RecordClickHandler() {
        @Override
        public void onRecordClick(RecordClickEvent recordClickEvent) {
            //gridWayBillSetGrid.getHiliteState()
            //make RECORD_VIEWED_STATUS value "true"
            recordClickEvent.getRecord().setAttribute("RECORD_VIEWED_STATUS", true);
            gridWayBillSetGrid.enableHilite("0", true);

        }
    });

但是当我点击记录时,样式没有显示出来。 请善意为此提供建议。

1 个答案:

答案 0 :(得分:0)

试试这个(覆盖getCellCSSText类的ListGrid方法):

ListGrid grid = new ListGrid(...){

            @Override
            protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {  
                if("true".equalsIgnoreCase(record.getAttribute("RECORD_VIEWED_STATUS"))){
                    return "font-style:italic;color:#525252;";
                }
                return super.getCellCSSText(record, rowNum, colNum);  
            }
        };