PDA

View Full Version : Color Grid Rows



baczek00
25 Oct 2014, 4:46 AM
Hello,
I have a data grid and I would like more on this grid to distinguish the color of some rows.

The color depends on the data rows in the grid.

The EXT-GWT 2.2.5 I've done it like this:



@Override
public final void addGridColumn(String ColumnDatabaseName, String ColumnName, Integer ColumnSize) {
final String cm = ColumnName;
GridCellRenderer<ModelData> colorRow = new GridCellRenderer<ModelData>() {
@Override
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
String val = (String) model.get(property);
if (val == null) {
val = "";
}
String valColor = (String) model.get("ZALEGLE");
String style = valColor != null ? "red" : GXT.isHighContrastMode ? "#00ff5a" : "#000000";
return "<span qtitle='" + cm + "' qtip='" + val
+ "' style='font-weight: normal;color:" + style + "'>" + val + "</span>";
}
};
ColumnConfig column = new ColumnConfig();
column.setHeader(ColumnName);
column.setId(ColumnDatabaseName.toUpperCase());
column.setWidth(ColumnSize);
column.setRenderer(colorRow);
addGridColumnCustom(column, true);



How to do it in EXT-GWT 3.1.1?

Andreas Samjeske
27 Oct 2014, 2:33 AM
In GXT3, ColumnConfig has setCell(myCell) rather hat setRenderer(myRenderer).

How to create a Cell and get access to the store within it, has been discussed here recently:

http://www.sencha.com/forum/showthread.php?210748-Tooltip-on-a-grid-cell