GXT - 根据行中的一个单元格整列整个网格行

Ami*_*ith 3 grid gxt

..我根据单元格的值着色了一列,但我想在gxt网格中为整行(表示包含行的单元格)着色帮助我这里是我的单元格着色代码(我想为行而不是单元格着色)

 /*------------Coloring Area------------*/
                    GridCellRenderer<BeanModelType> ColoredGrid = new GridCellRenderer<BeanModelType>() {

                        @Override
                        public Object render(BeanModelType model,
                                String property, ColumnData config,
                                int rowIndex, int colIndex,
                                ListStore<BeanModelType> store,
                                Grid<BeanModelType> grid) {

                            String valueOfCell =  model.get(property);    
                            String style = valueOfCell.equals("Book") ? "GREEN":
                            valueOfCell.equals("Ersr") ? "red":
                            valueOfCell.equals("Pen") ? "yellow":
                            valueOfCell.equals("comp") ? "blue": "";
                            //Config is the cell and we are setting style here

                            config.style ="background-color:"+style;
                            return valueOfCell; 



                        }    

                        };  
                        System.out.println("COLORRRRR   "+cleanColoredGrid.toString());
                        column.setRenderer(ColoredGrid);  

                    /*-------------Coloring Area Ends-------*/
                    configs.add(column); 
Run Code Online (Sandbox Code Playgroud)

Mar*_*Dec 8

鉴于您使用的是GXT> 2.xx,正确的方法是将新的GridViewConfig附加到网格视图中.

你可能应该这样做:

grid.getView().setViewConfig(new GridViewConfig() {
        @Override
        public String getRowStyle(ModelData model, int rowIndex, ListStore<ModelData> ds) {
            if (model != null) {
                                    //TODO: put your conditions here
                if ("YOUR_CONDITION".equals(model.get("BOOK_COLOR))) {
                    return "green-row";
                }
            }
            return "";
        }
    });
Run Code Online (Sandbox Code Playgroud)

你应该相应地修改你的CSS.(请注意,green-row是css样式类的名称).

请参阅此参考:http://www.jarvana.com/jarvana/view/com/extjs/gxt/2.1.1/gxt-2.1.1-javadoc.jar! /gxt-2.1.1-javadoc/com/ExtJS的/ GXT/UI /客户/空间/格/ GridViewConfig.html