.getSortableContainerPropertyIds().contains(
propertyId));
}
-
- // Add by default property id as column header
- row.getCell(propertyId).setText(String.valueOf(propertyId));
}
}
}
GridColumn column = new GridColumn(this, columnState);
columns.put(datasourcePropertyId, column);
+ column.setHeaderCaption(String.valueOf(datasourcePropertyId));
return column;
}
import com.vaadin.data.util.converter.ConverterUtil;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ui.grid.GridColumnState;
-import com.vaadin.shared.ui.grid.GridStaticSectionState.CellState;
import com.vaadin.ui.UI;
+import com.vaadin.ui.components.grid.GridHeader.HeaderRow;
import com.vaadin.ui.components.grid.renderers.TextRenderer;
/**
* @throws IllegalStateException
* if the column no longer is attached to the grid
*/
- @Deprecated
public String getHeaderCaption() throws IllegalStateException {
checkColumnIsAttached();
- return state.header;
+ HeaderRow row = grid.getHeader().getDefaultRow();
+ if (row != null) {
+ return row.getCell(grid.getPropertyIdByColumnId(state.id))
+ .getText();
+ }
+ return null;
}
/**
* @throws IllegalStateException
* if the column is no longer attached to any grid
*/
- @Deprecated
public void setHeaderCaption(String caption) throws IllegalStateException {
checkColumnIsAttached();
- state.header = caption;
- }
-
- /**
- * Returns the caption of the footer. By default the captions are
- * <code>null</code>.
- *
- * @return the text in the footer
- * @throws IllegalStateException
- * if the column is no longer attached to any grid
- */
- @Deprecated
- public String getFooterCaption() throws IllegalStateException {
- checkColumnIsAttached();
- return getFooterCellState().text;
- }
-
- /**
- * Sets the caption of the footer.
- *
- * @param caption
- * the text to show in the caption
- *
- * @throws IllegalStateException
- * if the column is no longer attached to any grid
- */
- @Deprecated
- public void setFooterCaption(String caption) throws IllegalStateException {
- checkColumnIsAttached();
- getFooterCellState().text = caption;
- state.footer = caption;
- grid.markAsDirty();
- }
-
- private CellState getFooterCellState() {
- int index = grid.getState().columns.indexOf(state);
- return grid.getState().footer.rows.get(0).cells.get(index);
+ HeaderRow row = grid.getHeader().getDefaultRow();
+ if (row != null) {
+ row.getCell(grid.getPropertyIdByColumnId(state.id))
+ .setText(caption);
+ }
}
/**
}
/**
- * Returns the cell at the given position in this row.
+ * Returns the cell for the given property id on this row.
*
* @param propertyId
- * the itemId of column
- * @return the cell on given column
- * @throws IndexOutOfBoundsException
- * if the index is out of bounds
+ * the property id of the column
+ * @return the cell for the given property or null if not found
*/
public CELLTYPE getCell(Object propertyId) {
return cells.get(propertyId);
column.setHeaderCaption("CustomHeader");
assertEquals("CustomHeader", column.getHeaderCaption());
- assertEquals(column.getHeaderCaption(),
- getColumnState("column1").header);
+ assertEquals(column.getHeaderCaption(), grid.getHeader()
+ .getDefaultRow().getCell("column1").getText());
column.setVisible(false);
assertFalse(column.isVisible());
// Detached state should throw exception
}
- try {
- column.setFooterCaption("asd");
- fail("Succeeded in modifying a detached column");
- } catch (IllegalStateException ise) {
- // Detached state should throw exception
- }
-
try {
column.setVisible(false);
fail("Succeeded in modifying a detached column");