Browse Source

Set column captions when reading grid from a design file (#8770)

Fixes #8752
tags/8.1.0.alpha2
Artur 7 years ago
parent
commit
52359708ad

+ 12
- 0
server/src/main/java/com/vaadin/ui/Grid.java View File

@@ -87,6 +87,7 @@ import com.vaadin.shared.ui.grid.GridConstants;
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;
@@ -102,6 +103,7 @@ import com.vaadin.ui.components.grid.FooterRow;
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;
@@ -3892,6 +3894,16 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
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());
}
}
}
}

protected void readData(Element body,

+ 2
- 4
server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java View File

@@ -802,11 +802,9 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {

// 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

Loading…
Cancel
Save