this.grid = grid;
- // enforce width set before attachment
+ setVisible(this.visible);
setWidth(this.width);
}
return;
}
+ this.visible = visible;
+
// Remove column
if (grid != null) {
int index = findIndexOfColumn();
}
}
- this.visible = visible;
}
/**
*
*/
private int findIndexOfColumn() {
- return grid.columns.indexOf(this);
+ return grid.findVisibleColumnIndex((GridColumn<?, T>) this);
}
/**
public void setWidth(int pixels) {
this.width = pixels;
- if (grid != null) {
+ if (grid != null && isVisible()) {
int index = findIndexOfColumn();
ColumnConfiguration conf = grid.escalator
.getColumnConfiguration();
if (firstRowIsVisible() && rowIndex == 0) {
// column headers
for (Cell cell : cellsToUpdate) {
- int columnIndex = cell.getColumn();
- GridColumn<?, T> column = columns.get(columnIndex);
- cell.getElement().setInnerText(getColumnValue(column));
+ GridColumn<?, T> column = getColumnFromVisibleIndex(cell
+ .getColumn());
+ if (column != null) {
+ cell.getElement().setInnerText(getColumnValue(column));
+ }
}
} else if (columnGroupRows.size() > 0) {
assert groupRow != null;
for (Cell cell : cellsToUpdate) {
- int columnIndex = cell.getColumn();
- GridColumn<?, T> column = columns.get(columnIndex);
+ GridColumn<?, T> column = getColumnFromVisibleIndex(cell
+ .getColumn());
ColumnGroup<T> group = getGroupForColumn(groupRow, column);
Element cellElement = cell.getElement();
}
for (Cell cell : cellsToUpdate) {
- GridColumn column = getColumn(cell.getColumn());
- Object value = column.getValue(rowData);
- column.getRenderer().renderCell(cell, value);
+ GridColumn column = getColumnFromVisibleIndex(cell
+ .getColumn());
+ if (column != null) {
+ Object value = column.getValue(rowData);
+ column.getRenderer().renderCell(cell, value);
+ }
}
}
}
}
+ private int findVisibleColumnIndex(GridColumn<?, T> column) {
+ int idx = 0;
+ for (GridColumn<?, T> c : columns) {
+ if (c == column) {
+ return idx;
+ } else if (c.isVisible()) {
+ idx++;
+ }
+ }
+ return -1;
+ }
+
+ private GridColumn<?, T> getColumnFromVisibleIndex(int index) {
+ int idx = -1;
+ for (GridColumn<?, T> c : columns) {
+ if (c.isVisible()) {
+ idx++;
+ }
+ if (index == idx) {
+ return c;
+ }
+ }
+ return null;
+ }
+
/**
* Removes a column from the grid.
*