Skip to content

Commit

Permalink
Set column captions when reading grid from a design file (#8770)
Browse files Browse the repository at this point in the history
Fixes #8752
  • Loading branch information
Artur- authored and hesara committed Mar 22, 2017
1 parent db46ab7 commit 07220bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 12 additions & 0 deletions server/src/main/java/com/vaadin/ui/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import com.vaadin.shared.ui.grid.GridConstants.Section;
import com.vaadin.shared.ui.grid.GridServerRpc;
import com.vaadin.shared.ui.grid.GridState;
import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.shared.ui.grid.ScrollDestination;
import com.vaadin.shared.ui.grid.SectionState;
Expand All @@ -102,6 +103,7 @@
import com.vaadin.ui.components.grid.GridSelectionModel;
import com.vaadin.ui.components.grid.Header;
import com.vaadin.ui.components.grid.Header.Row;
import com.vaadin.ui.components.grid.HeaderCell;
import com.vaadin.ui.components.grid.HeaderRow;
import com.vaadin.ui.components.grid.ItemClickListener;
import com.vaadin.ui.components.grid.MultiSelectionModel;
Expand Down Expand Up @@ -3817,6 +3819,16 @@ private void readStructure(Element design, DesignContext context) {
getFooter().readDesign(child, context);
}
}

// Sync default header captions to column captions
if (getDefaultHeaderRow() != null) {
for (Column<T, ?> c : getColumns()) {
HeaderCell headerCell = getDefaultHeaderRow().getCell(c);
if (headerCell.getCellType() == GridStaticCellType.TEXT) {
c.setCaption(headerCell.getText());
}
}
}
}

private void readData(Element body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,9 @@ private void assertColumns(int expectedCount,

// Property mapping
Assert.assertEquals(expectedColumn.getId(), column.getId());
// Not tested because of
// https://github.com/vaadin/framework/issues/8752
// Header caption
// Assert.assertEquals(expectedColumn.getCaption(),
// column.getCaption());
Assert.assertEquals(expectedColumn.getCaption(),
column.getCaption());

// Value providers are not stored in the declarative file
// so this only works for bean properties
Expand Down

0 comments on commit 07220bb

Please sign in to comment.