private Converter<?, Object> converter;
/**
- * A check for allowing the {@link #Column(Grid, GridColumnState, Object)
- * constructor} to call {@link #setConverter(Converter)} with a
- * <code>null</code>, even if model and renderer aren't compatible.
+ * A check for allowing the
+ * {@link #Column(Grid, GridColumnState, Object) constructor} to call
+ * {@link #setConverter(Converter)} with a <code>null</code>, even if
+ * model and renderer aren't compatible.
*/
private boolean isFirstConverterAssignment = true;
}
/**
- * Sets the caption of the header.
+ * Sets the caption of the header. This caption is also used as the
+ * hiding toggle caption, unless it is explicitly set via
+ * {@link #setHidingToggleCaption(String)}.
*
* @param caption
* the text to show in the caption
public Column setHeaderCaption(String caption)
throws IllegalStateException {
checkColumnIsAttached();
+
+ state.headerCaption = caption;
+
HeaderRow row = grid.getHeader().getDefaultRow();
if (row != null) {
row.getCell(grid.getPropertyIdByColumnId(state.id)).setText(
* toggle for this column in the grid's sidebar when the column is
* {@link #isHidable() hidable}.
* <p>
- * By default, before triggering this setter, a user friendly version of
- * the column's {@link #getPropertyId() property id} is used.
+ * The default value is <code>null</code>, and in that case the column's
+ * {@link #getHeaderCaption() header caption} is used.
* <p>
- * <em>NOTE:</em> setting this to <code>null</code> or empty string
- * might cause the hiding toggle to not render correctly.
+ * <em>NOTE:</em> setting this to empty string might cause the hiding
+ * toggle to not render correctly.
*
* @since 7.5.0
* @param hidingToggleCaption
DesignAttributeHandler.writeAttribute("hidden", attributes,
isHidden(), def.hidden, boolean.class);
DesignAttributeHandler.writeAttribute("hiding-toggle-caption",
- attributes, getHidingToggleCaption(),
- SharedUtil.propertyIdToHumanFriendly(getPropertyId()),
- String.class);
+ attributes, getHidingToggleCaption(), null, String.class);
DesignAttributeHandler.writeAttribute("property-id", attributes,
getPropertyId(), null, Object.class);
}
private final String nullRepresentation;
- protected AbstractRenderer(Class<T> presentationType, String nullRepresentation) {
+ protected AbstractRenderer(Class<T> presentationType,
+ String nullRepresentation) {
this.presentationType = presentationType;
this.nullRepresentation = nullRepresentation;
}
/**
* Null representation for the renderer
+ *
* @return a textual representation of {@code null}
*/
protected String getNullRepresentation() {
String humanFriendlyPropertyId = SharedUtil
.propertyIdToHumanFriendly(String.valueOf(datasourcePropertyId));
column.setHeaderCaption(humanFriendlyPropertyId);
- column.setHidingToggleCaption(humanFriendlyPropertyId);
if (datasource instanceof Sortable
&& ((Sortable) datasource).getSortableContainerPropertyIds()
* @throws IllegalArgumentException
* if {@code rows} is zero or less
* @throws IllegalArgumentException
- * if {@code rows} is {@link Double#isInfinite(double)
- * infinite}
+ * if {@code rows} is {@link Double#isInfinite(double) infinite}
* @throws IllegalArgumentException
* if {@code rows} is {@link Double#isNaN(double) NaN}
*/
assertEquals("Column 1", getColumnHidingToggle(1).getText());
}
+ @Test
+ public void testColumnHidingToggleCaption_settingColumnHeaderCaption_toggleCaptionIsEqual() {
+ toggleColumnHidable(1);
+
+ selectMenuPath("Component", "Columns", "Column 1",
+ "Change header caption");
+
+ getSidebarOpenButton().click();
+ assertEquals("column 1 header 0", getGridElement().getHeaderCell(0, 1)
+ .getText().toLowerCase());
+ assertEquals("Column 1 header 0", getColumnHidingToggle(1).getText());
+ }
+
+ @Test
+ public void testColumnHidingToggleCaption_explicitlySet_toggleCaptionIsNotOverridden() {
+ toggleColumnHidable(1);
+
+ selectMenuPath("Component", "Columns", "Column 1",
+ "Change hiding toggle caption");
+ selectMenuPath("Component", "Columns", "Column 1",
+ "Change header caption");
+
+ getSidebarOpenButton().click();
+ assertEquals("column 1 header 0", getGridElement().getHeaderCell(0, 1)
+ .getText().toLowerCase());
+ assertEquals("Column 1 caption 0", getColumnHidingToggle(1).getText());
+ }
+
private void toggleColumnHidingToggleCaptionChange(int index) {
selectMenuPath("Component", "Columns", "Column " + index,
"Change hiding toggle caption");