gpt4 book ai didi

grid - GXT - 根据行中的一个单元格为整个网格行着色

转载 作者:行者123 更新时间:2023-12-01 08:36:50 25 4
gpt4 key购买 nike

。 . 我根据单元格的值为一列着色,但我想在 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);

最佳答案

鉴于您使用的是 GXT > 2.x.x,正确的做法是将新的 GridViewConfig 附加到您的 GridView 。

你可能应该这样做:

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

您应该相应地修改您的 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/client/widget/grid/GridViewConfig.html

关于grid - GXT - 根据行中的一个单元格为整个网格行着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8830617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com