gridColumnVisibility
gridColumnVisibility lets users show or hide columns in a dataGrid.
XML Element |
|
|---|---|
Java Class |
|
Basics
gridColumnVisibility consists of a button and a dropdown menu with the list of columns.
Below is an example of using gridColumnVisibility in a list view:
<hbox id="buttonsPanel" classNames="buttons-panel">
<!-- ... -->
<gridColumnVisibility dataGrid="stepsTable"
icon="COG"
themeNames="icon"
exclude="duration">
<menuItem refColumn="name" text="msg://menuItem.text"/>
</gridColumnVisibility>
</hbox>
<dataGrid id="stepsTable"
width="100%"
minHeight="20em"
dataContainer="stepsDc">
<columns>
<column property="name"/>
<column property="duration"/>
<column property="sortValue"/>
</columns>
</dataGrid>
Setting Up Dropdown Menu
menuItem
By default, the item text is copied from the column header. You can customize this using the menuItem element.
For example, in the previous example, the menuItem element is used to set a different localized message for the name column than the one specified in the dataGrid header.
include
The include attribute is used to specify which columns should be included in a dropdown menu of gridColumnVisibility.
exclude
The exclude attribute is used to specify which columns should be excluded from a dropdown menu of gridColumnVisibility.
For example, in the previous example, we excluded the duration column from the gridColumnVisibility dropdown menu.
Theme Variants
Use the themeNames attribute to apply one or more theme variants.
| Variant | Description | Supported By |
|---|---|---|
|
Applies the primary button style. |
Aura, Lumo |
|
Applies a lower-emphasis button style. |
Aura, Lumo |
|
Applies an inline button style intended for use inside text content. |
Lumo |
|
Reduces the whitespace around the icon. |
Lumo |
|
Makes the button smaller. |
Aura, Lumo |
|
Makes the button larger. |
Aura, Lumo |
|
Applies the success style. |
Aura, Lumo |
|
Applies the error style. |
Aura, Lumo |
|
Applies the contrast style. |
Lumo |
Attributes
The following attributes are specific to gridColumnVisibility:
| Name | Description | Default |
|---|---|---|
Sets a grid which columns will be managed by this component. |
— |
|
|
Specifies columns to exclude from the visibility menu. See exclude. |
— |
|
Controls whether the visibility menu contains the Hide all item. See hideAllEnabled. |
— |
Sets the icon. |
— |
|
|
Specifies columns to include in the visibility menu. See include. |
— |
|
Controls whether the visibility menu contains the Show all item. See showAllEnabled. |
— |
The following shared attributes are supported by gridColumnVisibility:
id - alignSelf - classNames - colspan - css - enabled - focusShortcut - height - maxHeight - maxWidth - minHeight - minWidth - tabIndex - text - themeNames - visible - whiteSpace - width
Elements
A gridColumnVisibility can include menuItem as its nested elements.