use of org.zkoss.zul.Grid in project adempiere by adempiere.
the class GridTabRowRenderer method render.
/**
* @param row
* @param data
* @see RowRenderer#render(Row, Object)
*/
public void render(Row row, Object[] data, int index) throws Exception {
//don't render if not visible
if (gridPanel != null && !gridPanel.isVisible()) {
return;
}
if (grid == null)
grid = (Grid) row.getParent().getParent();
if (rowListener == null)
rowListener = new RowListener((Grid) row.getParent().getParent());
currentValues = data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
Grid grid = (Grid) row.getParent().getParent();
org.zkoss.zul.Columns columns = grid.getColumns();
int rowIndex = row.getParent().getChildren().indexOf(row);
if (paging != null && paging.getPageSize() > 0) {
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
int colIndex = -1;
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed())) {
continue;
}
colIndex++;
Div div = new Div();
ThemeUtils.addSclass("ad-gridtabrowrenderer", div);
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) {
Component component = getDisplayComponent(currentValues[i], gridField[i]);
div.appendChild(component);
// if (compCount == 1) {
//add hidden input component to help focusing to row
div.appendChild(createAnchorInput());
if (DisplayType.YesNo == gridField[i].getDisplayType() || DisplayType.Image == gridField[i].getDisplayType()) {
ThemeUtils.addSclass("yes-no", div);
//divStyle += "text-align:center; ";
} else if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
ThemeUtils.addSclass("numeric", div);
//divStyle += "text-align:right; ";
}
}
div.setAttribute("columnName", gridField[i].getColumnName());
div.addEventListener(Events.ON_CLICK, rowListener);
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
row.appendChild(div);
}
if (rowIndex == gridTab.getCurrentRow()) {
setCurrentRow(row);
}
row.addEventListener(Events.ON_OK, rowListener);
}
Aggregations