<li><tt>TreeGrid.createColumn()</tt> has an additional parameter.</li>
<li><tt>LocalDateTimeToDateConverter</tt> now uses <tt>ZoneId</tt> instead of <tt>ZoneOffset</tt>.</li>
<li><tt>FontAwesome</tt> icon alignment in <tt>ComboBox</tt> has changed in the theme.</li>
- <li><tt>GridState</tt> variable <tt>rowHeight</tt> has replaced by three variables.</li>
<h2>For incompatible or behaviour-altering changes in 8.0, please see <a href="https://vaadin.com/download/release/8.0/8.0.0/release-notes.html#incompatible">8.0 release notes</a></h2>
import com.vaadin.client.connectors.grid.ColumnConnector.CustomColumn;
import com.vaadin.client.data.DataSource;
import com.vaadin.client.ui.SimpleManagedLayout;
-import com.vaadin.client.widget.escalator.RowContainer;
import com.vaadin.client.widget.grid.CellReference;
import com.vaadin.client.widget.grid.EventCellReference;
import com.vaadin.client.widget.grid.events.BodyClickHandler;
/* Child component list for HasComponentsConnector */
private List<ComponentConnector> childComponents;
private ItemClickHandler itemClickHandler = new ItemClickHandler();
- private boolean rowHeightScheduled = false;
/**
* Gets the string identifier of the given column in this grid.
grid.setHeaderVisible(state.visible);
}
- @OnStateChange({ "bodyRowHeight", "headerRowHeight", "footerRowHeight" })
+ @OnStateChange("rowHeight")
void updateRowHeight() {
- if (rowHeightScheduled) {
- return;
- }
-
- Scheduler.get().scheduleFinally(() -> {
- GridState state = getState();
- if (getWidget().isAttached() && rowHeightNeedsReset()) {
- getWidget().resetSizesFromDom();
- }
- updateContainerRowHeigth(getWidget().getEscalator().getBody(),
- state.bodyRowHeight);
- updateContainerRowHeigth(getWidget().getEscalator().getHeader(),
- state.headerRowHeight);
- updateContainerRowHeigth(getWidget().getEscalator().getFooter(),
- state.footerRowHeight);
- rowHeightScheduled = false;
- });
-
- rowHeightScheduled = true;
- }
-
- private boolean rowHeightNeedsReset() {
- GridState state = getState();
- // Body
- boolean bodyAutoCalc = state.bodyRowHeight < 0;
-
- // Header
- boolean headerAutoCalc = state.headerRowHeight < 0;
- boolean headerReset = headerAutoCalc && hasVisibleContent(state.header);
-
- // Footer
- boolean footerAutoCalc = state.footerRowHeight < 0;
- boolean footerReset = footerAutoCalc && hasVisibleContent(state.footer);
-
- return bodyAutoCalc || headerReset || footerReset;
- }
-
- private boolean hasVisibleContent(SectionState state) {
- return state.visible && !state.rows.isEmpty();
- }
-
- private void updateContainerRowHeigth(RowContainer container,
- double height) {
- if (height >= 0) {
- container.setDefaultRowHeight(height);
+ double rowHeight = getState().rowHeight;
+ if (rowHeight >= 0) {
+ getWidget().getEscalator().getHeader()
+ .setDefaultRowHeight(rowHeight);
+ getWidget().getEscalator().getBody().setDefaultRowHeight(rowHeight);
+ getWidget().getEscalator().getFooter()
+ .setDefaultRowHeight(rowHeight);
+ } else if (getWidget().isAttached()) {
+ // finally to make sure column sizes have been set before this
+ Scheduler.get()
+ .scheduleFinally(() -> getWidget().resetSizesFromDom());
}
}
[classname]#ComponentRenderer#:: Renders a Vaadin [classname]#Component# in a column. Since components
are quite complex, the [classname]#ComponentRenderer# comes with possible performance issues.
To use it efficiently you should use as few nested components as possible. If the components used are
-of a different size than the default row height, [methodname]#Grid.setBodyRowHeight()# can be used to adjust
+of a different size than the default row height, [methodname]#Grid.setRowHeight()# can be used to adjust
the height of all rows in the Grid.
+
return button;
});
// make sure the buttons fit in the cells of the Grid
-grid.setBodyRowHeight(40);
+grid.setRowHeight(40);
----
+
Components will occasionally be generated again during runtime. If you have a state in your
}
/**
- * Sets the height of body, header and footer rows. If -1 (default), the row
- * height is calculated based on the theme for an empty row before the Grid
- * is displayed.
+ * Sets the height of a row. If -1 (default), the row height is calculated
+ * based on the theme for an empty row before the Grid is displayed.
* <p>
* Note that all header, body and footer rows get the same height if
* explicitly set. In automatic mode, each section is calculated separately
* based on an empty row of that type.
- *
- * @see #setBodyRowHeight(double)
- * @see #setHeaderRowHeight(double)
- * @see #setFooterRowHeight(double)
*
* @param rowHeight
* The height of a row in pixels or -1 for automatic calculation
*/
public void setRowHeight(double rowHeight) {
- setBodyRowHeight(rowHeight);
- setHeaderRowHeight(rowHeight);
- setFooterRowHeight(rowHeight);
- }
-
- /**
- * Sets the height of a body row. If -1 (default), the row height is
- * calculated based on the theme for an empty row before the Grid is
- * displayed.
- *
- * @param rowHeight
- * The height of a row in pixels or -1 for automatic calculation
- * @since 8.1.2
- */
- public void setBodyRowHeight(double rowHeight) {
- getState().bodyRowHeight = rowHeight;
- }
-
- /**
- * Sets the height of a header row. If -1 (default), the row height is
- * calculated based on the theme for an empty row before the Grid is
- * displayed.
- *
- * @param rowHeight
- * The height of a row in pixels or -1 for automatic calculation
- * @since 8.1.2
- */
- public void setHeaderRowHeight(double rowHeight) {
- getState().headerRowHeight = rowHeight;
+ getState().rowHeight = rowHeight;
}
/**
- * Sets the height of a footer row. If -1 (default), the row height is
- * calculated based on the theme for an empty row before the Grid is
- * displayed.
+ * Returns the currently explicitly set row height or -1 if automatic.
*
- * @param rowHeight
- * The height of a row in pixels or -1 for automatic calculation
- * @since 8.1.2
+ * @return explicitly set row height in pixels or -1 if in automatic mode
*/
- public void setFooterRowHeight(double rowHeight) {
- getState().footerRowHeight = rowHeight;
- }
-
- /**
- * Returns the current body row height.-1 if row height is in automatic
- * calculation mode.
- *
- * @see #getBodyRowHeight()
- * @see #getHeaderRowHeight()
- * @see #getFooterRowHeight()
- *
- * @return body row height
- * @deprecated replaced by three separate row height controls
- */
- @Deprecated
public double getRowHeight() {
- return getBodyRowHeight();
- }
-
- /**
- * Returns the current body row height. -1 if row height is in automatic
- * calculation mode.
- *
- * @return body row height
- * @since 8.1.2
- */
- public double getBodyRowHeight() {
- return getState(false).bodyRowHeight;
- }
-
- /**
- * Returns the current header row height. -1 if row height is in automatic
- * calculation mode.
- *
- * @return header row height
- * @since 8.1.2
- */
- public double getHeaderRowHeight() {
- return getState(false).headerRowHeight;
- }
-
- /**
- * Returns the current footer row height. -1 if row height is in automatic
- * calculation mode.
- *
- * @return footer row height
- * @since 8.1.2
- */
- public double getFooterRowHeight() {
- return getState(false).footerRowHeight;
+ return getState(false).rowHeight;
}
/**
public boolean columnReorderingAllowed;
/**
- * Explicit body row height in pixels for grid rows, or -1 to calculate
+ * Explicit row height in pixels for grid rows, or -1 to calculate
* automatically based on the theme.
*
- * @since 8.1.2
+ * @since 8.1
*/
- public double bodyRowHeight = -1;
+ public double rowHeight = -1;
- /**
- * Explicit body row height in pixels for grid rows, or -1 to calculate
- * automatically based on the theme.
- *
- * @since 8.1.2
- */
- public double headerRowHeight = -1;
-
- /**
- * Explicit body row height in pixels for grid rows, or -1 to calculate
- * automatically based on the theme.
- *
- * @since 8.1.2
- */
- public double footerRowHeight = -1;
}
rowMenu.addItem("Deselect all", menuItem -> {
grid.getSelectionModel().deselectAll();
});
-
- MenuItem rowHeight = rowMenu.addItem("Body Row Height", null);
- Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i,
- menuItem -> grid.setBodyRowHeight(i)));
}
private void createSelectionMenu(MenuItem stateItem) {
headerMenu.addItem("Merge Header Cells [0,6..7]", menuItem -> {
mergeHeaderСells(0, "6+7", 6, 7);
});
-
- MenuItem rowHeight = headerMenu.addItem("Header Row Height", null);
- Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i,
- menuItem -> grid.setHeaderRowHeight(i)));
}
private void mergeHeaderСells(int rowIndex, String jointCellText,
footerMenu.addItem("Merge Footer Cells [0,6..7]", menuItem -> {
mergeFooterСells(0, "6+7", 6, 7);
});
-
- MenuItem rowHeight = footerMenu.addItem("Footer Row Height", null);
- Stream.of(-1, 20, 50, 100).forEach(i -> rowHeight.addItem("" + i,
- menuItem -> grid.setFooterRowHeight(i)));
}
/* DetailsGenerator related things */
public class GridRowHeightTest extends GridBasicsTest {
- @Test
- public void testSeparateRowHeights() {
- selectMenuPath("Component", "Footer", "Add default footer row");
-
- int initialHeaderHeight = getHeaderHeight();
-
- Assert.assertNotEquals("Header height should not be 50px initially", 50,
- initialHeaderHeight);
-
- selectMenuPath("Component", "Body rows", "Body Row Height", "" + 100);
- selectMenuPath("Component", "Header", "Header Row Height", "" + 20);
- selectMenuPath("Component", "Footer", "Footer Row Height", "" + 50);
-
- checkRowHeights(20, 100, 50);
-
- selectMenuPath("Component", "Header", "Header Row Height", "" + -1);
-
- checkRowHeights(initialHeaderHeight, 100, 50);
- }
-
@Test
public void testRowHeights() {
selectMenuPath("Component", "Footer", "Add default footer row");