T - the grid bean typepublic class Grid<T> extends AbstractListing<T> implements HasComponents, HasDataProvider<T>, SortEvent.SortNotifier<GridSortOrder<T>>
| Modifier and Type | Class and Description |
|---|---|
static class |
Grid.AbstractGridExtension<T>
A helper base class for creating extensions for the Grid component.
|
static class |
Grid.Column<T,V>
This extension manages the configuration and data communication for a
Column inside of a Grid component.
|
static class |
Grid.ColumnReorderEvent
An event that is fired when the columns are reordered.
|
static class |
Grid.ColumnResizeEvent
An event that is fired when a column is resized, either programmatically
or by the user.
|
static class |
Grid.ColumnVisibilityChangeEvent
An event that is fired when a column's visibility changes.
|
static class |
Grid.DetailsManager<T>
Class for managing visible details rows.
|
static interface |
Grid.FetchItemsCallback<T>
A callback method for fetching items.
|
static class |
Grid.GridContextClickEvent<T>
ContextClickEvent for the Grid Component.
|
static class |
Grid.ItemClick<T>
An event fired when an item in the Grid has been clicked.
|
static class |
Grid.SelectionMode
Selection mode representing the built-in selection models in grid.
|
AbstractListing.AbstractListingExtension<T>HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListenerComponent.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitDESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Modifier | Constructor and Description |
|---|---|
|
Grid()
Creates a new grid without support for creating columns based on property
names.
|
|
Grid(Class<T> beanType)
Creates a new grid that uses reflection based on the provided bean type
to automatically set up an initial set of columns.
|
protected |
Grid(Class<T> beanType,
DataCommunicator<T> dataCommunicator)
Creates a new grid that uses custom data communicator and provided bean
type
It uses reflection of the provided bean type to automatically set up an
initial set of columns.
|
protected |
Grid(DataCommunicator<T> dataCommunicator)
Creates a new grid with the given data communicator and without support
for creating columns based on property names.
|
|
Grid(DataProvider<T,?> dataProvider)
Creates a new
Grid using the given DataProvider. |
protected |
Grid(PropertySet<T> propertySet)
Creates a grid using a custom
PropertySet implementation for
configuring the initial columns and resolving property names for
addColumn(String) and
Grid.Column.setEditorComponent(HasValue). |
protected |
Grid(PropertySet<T> propertySet,
DataCommunicator<T> dataCommunicator)
Creates a grid using a custom
PropertySet implementation and
custom data communicator. |
|
Grid(String caption)
Creates a new
Grid using the given caption. |
|
Grid(String caption,
Collection<T> items)
Creates a new
Grid using the given caption and collection of
items. |
|
Grid(String caption,
DataProvider<T,?> dataProvider)
Creates a new
Grid using the given caption and
DataProvider. |
| Modifier and Type | Method and Description |
|---|---|
Grid.Column<T,?> |
addColumn(String propertyName)
Adds a new column with the given property name.
|
Grid.Column<T,?> |
addColumn(String propertyName,
AbstractRenderer<? super T,?> renderer)
Adds a new column with the given property name and renderer.
|
Grid.Column<T,?> |
addColumn(String propertyName,
AbstractRenderer<? super T,?> renderer,
Grid.Column.NestedNullBehavior nestedNullBehavior)
Adds a new column with the given property name and renderer.
|
<V> Grid.Column<T,V> |
addColumn(ValueProvider<T,V> valueProvider)
Adds a new text column to this
Grid with a value provider. |
<V> Grid.Column<T,V> |
addColumn(ValueProvider<T,V> valueProvider,
AbstractRenderer<? super T,? super V> renderer)
Adds a new column to this
Grid with typed renderer and value
provider. |
<V,P> Grid.Column<T,V> |
addColumn(ValueProvider<T,V> valueProvider,
ValueProvider<V,P> presentationProvider,
AbstractRenderer<? super T,? super P> renderer)
Adds a new column to this
Grid with value provider, presentation
provider and typed renderer. |
<V> Grid.Column<T,V> |
addColumn(ValueProvider<T,V> valueProvider,
ValueProvider<V,String> presentationProvider)
Adds a new column to this
Grid with value provider and
presentation provider. |
Registration |
addColumnReorderListener(ColumnReorderListener listener)
Registers a new column reorder listener.
|
Registration |
addColumnResizeListener(ColumnResizeListener listener)
Registers a new column resize listener.
|
Registration |
addColumnVisibilityChangeListener(ColumnVisibilityChangeListener listener)
Registers a new column visibility change listener.
|
<V extends Component> |
addComponentColumn(ValueProvider<T,V> componentProvider)
Adds a column that shows components.
|
Registration |
addContextClickListener(ContextClickEvent.ContextClickListener listener)
Adds a context click listener that gets notified when a context click
happens.
|
FooterRow |
addFooterRowAt(int index)
Inserts a new row at the given position to the footer section.
|
HeaderRow |
addHeaderRowAt(int index)
Inserts a new row at the given position to the header section.
|
Registration |
addItemClickListener(ItemClickListener<? super T> listener)
Adds an item click listener.
|
Registration |
addSelectionListener(SelectionListener<T> listener)
Adds a selection listener to the current selection model.
|
Registration |
addSortListener(SortEvent.SortListener<GridSortOrder<T>> listener)
Adds a sort order change listener that gets notified when the sort order
changes.
|
FooterRow |
appendFooterRow()
Adds a new row at the bottom of the footer section.
|
HeaderRow |
appendHeaderRow()
Adds a new row at the bottom of the header section.
|
GridMultiSelect<T> |
asMultiSelect()
User this grid as a multiselect in
Binder. |
GridSingleSelect<T> |
asSingleSelect()
Use this grid as a single select in
Binder. |
void |
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the
client.
|
void |
clearSortOrder()
Clear the current sort order, and re-sort the grid.
|
protected <V,P> Grid.Column<T,V> |
createColumn(ValueProvider<T,V> valueProvider,
ValueProvider<V,P> presentationProvider,
AbstractRenderer<? super T,? super P> renderer)
Creates a column instance from a value provider, presentation provider
and a renderer.
|
protected Editor<T> |
createEditor()
Creates a new Editor instance.
|
protected SerializableComparator<T> |
createSortingComparator()
Creates a comparator for grid to sort rows.
|
void |
deselect(T item)
This method is a shorthand that delegates to the currently set selection
model.
|
void |
deselectAll()
This method is a shorthand that delegates to the currently set selection
model.
|
protected T |
deserializeDeclarativeRepresentation(String item)
Deserializes a string to a data item.
|
protected void |
doReadDesign(org.jsoup.nodes.Element design,
DesignContext context)
Reads the listing specific state from the given design.
|
protected void |
doWriteDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes listing specific state into the given design.
|
<V> void |
fireColumnVisibilityChangeEvent(Grid.Column<T,V> column,
boolean hidden,
boolean userOriginated)
Sends a
Grid.ColumnVisibilityChangeEvent to all listeners. |
Class<T> |
getBeanType()
Gets the bean type used by this grid.
|
double |
getBodyRowHeight()
Returns the current body row height.
|
Grid.Column<T,?> |
getColumn(String columnId)
Gets a
Grid.Column of this grid by its identifying string. |
protected Grid.Column<T,?> |
getColumnByInternalId(String columnId)
Returns a column identified by its internal id.
|
ColumnResizeMode |
getColumnResizeMode()
Returns the current column resize mode.
|
List<Grid.Column<T,?>> |
getColumns()
Gets an unmodifiable collection of all columns currently in this
Grid. |
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. |
DataProvider<T,?> |
getDataProvider()
Returns the source of data items used by this listing.
|
HeaderRow |
getDefaultHeaderRow()
Returns the current default row of the header.
|
DescriptionGenerator<T> |
getDescriptionGenerator()
Gets the description generator that is used for generating descriptions
for rows.
|
Editor<T> |
getEditor()
Returns the
Editor for this grid. |
protected Footer |
getFooter()
Returns the footer section of this grid.
|
FooterRow |
getFooterRow(int index)
Returns the footer row at the given index.
|
int |
getFooterRowCount()
Gets the number of rows in the footer section.
|
double |
getFooterRowHeight()
Returns the current footer row height.
|
int |
getFrozenColumnCount()
Gets the number of frozen columns in this grid.
|
protected Header |
getHeader()
Returns the header section of this grid.
|
HeaderRow |
getHeaderRow(int index)
Returns the header row at the given index.
|
int |
getHeaderRowCount()
Gets the number of rows in the header section.
|
double |
getHeaderRowHeight()
Returns the current header row height.
|
double |
getHeightByRows()
Gets the amount of rows in Grid's body that are shown, while
getHeightMode() is HeightMode.ROW. |
HeightMode |
getHeightMode()
Returns the current
HeightMode the Grid is in. |
protected String |
getInternalIdForColumn(Grid.Column<T,?> column)
Returns the internal id for given column.
|
protected PropertySet<T> |
getPropertySet()
Returns the property set used by this grid.
|
double |
getRowHeight()
Deprecated.
replaced by three separate row height controls
|
Set<T> |
getSelectedItems()
This method is a shorthand that delegates to the currently set selection
model.
|
GridSelectionModel<T> |
getSelectionModel()
Returns the selection model for this grid.
|
List<GridSortOrder<T>> |
getSortOrder()
Get the current sort order list.
|
protected GridState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected GridState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
StyleGenerator<T> |
getStyleGenerator()
Gets the style generator that is used for generating class names for
rows.
|
protected void |
internalSetDataProvider(DataProvider<T,?> dataProvider) |
boolean |
isColumnReorderingAllowed()
Returns whether column reordering is allowed.
|
boolean |
isDetailsVisible(T item)
Returns the visibility of details component for given item.
|
boolean |
isFooterVisible()
Gets the visibility of the Footer in this Grid.
|
boolean |
isHeaderVisible()
Gets the visibility of the Header in this Grid.
|
protected boolean |
isReadOnly()
Returns the read-only status from the state of this
AbstractComponent. |
Iterator<Component> |
iterator()
Gets an iterator to the collection of contained components.
|
FooterRow |
prependFooterRow()
Adds a new row at the top of the footer section.
|
HeaderRow |
prependHeaderRow()
Adds a new row at the top of the header section.
|
protected void |
readData(org.jsoup.nodes.Element body,
List<com.vaadin.ui.DeclarativeValueProvider<T>> providers)
Reads the declarative representation of a grid's data from the given
element and stores it in the given
DeclarativeValueProviders. |
protected void |
readItems(org.jsoup.nodes.Element design,
DesignContext context)
Reads the data source items from the
design. |
void |
recalculateColumnWidths()
Requests that the column widths should be recalculated.
|
void |
removeAllColumns()
Removes all columns from this Grid.
|
void |
removeColumn(Grid.Column<T,?> column)
Removes the given column from this
Grid. |
void |
removeColumn(String columnId)
Removes the column with the given column id.
|
void |
removeFooterRow(FooterRow row)
Removes the given row from the footer section.
|
void |
removeFooterRow(int index)
Removes the row at the given position from the footer section.
|
void |
removeHeaderRow(HeaderRow row)
Removes the given row from the header section.
|
void |
removeHeaderRow(int index)
Removes the row at the given position from the header section.
|
void |
scrollTo(int row)
Scrolls to a certain item, using
ScrollDestination.ANY. |
void |
scrollTo(int row,
ScrollDestination destination)
Scrolls to a certain item, using user-specified scroll destination.
|
void |
scrollToEnd()
Scrolls to the end of the last data row.
|
void |
scrollToStart()
Scrolls to the beginning of the first data row.
|
void |
select(T item)
This method is a shorthand that delegates to the currently set selection
model.
|
protected void |
setBeanType(Class<T> beanType)
Sets the bean type to use for property mapping.
|
protected void |
setBeanType(String beanTypeClassName)
Sets the bean type to use for property mapping.
|
void |
setBodyRowHeight(double rowHeight)
Sets the height of a body row.
|
protected void |
setColumnId(String id,
Grid.Column<T,?> column)
Sets a user-defined identifier for given column.
|
void |
setColumnOrder(Grid.Column<T,?>... columns)
Sets a new column order for the grid.
|
void |
setColumnOrder(String... columnIds)
Sets a new column order for the grid based on their column ids.
|
void |
setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether or not column reordering is allowed.
|
void |
setColumnResizeMode(ColumnResizeMode mode)
Sets the column resize mode to use.
|
void |
setColumns(Collection<String> columnIds)
Sets the columns and their order based on their column ids provided that
collection supports preserving of the order.
|
void |
setColumns(String... columnIds)
Sets the columns and their order based on their column ids.
|
void |
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
|
void |
setDataProvider(Grid.FetchItemsCallback<T> fetchItems,
SerializableSupplier<Integer> sizeCallback)
Sets a CallbackDataProvider using the given fetch items callback and a
size callback.
|
void |
setDefaultHeaderRow(HeaderRow row)
Sets the default row of the header.
|
void |
setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions
for rows.
|
void |
setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator,
ContentMode contentMode)
Sets the description generator that is used for generating descriptions
for rows.
|
void |
setDetailsGenerator(DetailsGenerator<T> generator)
Sets the details component generator.
|
void |
setDetailsVisible(T item,
boolean visible)
Sets the visibility of details component for given item.
|
void |
setFooterRowHeight(double rowHeight)
Sets the height of a footer row.
|
void |
setFooterVisible(boolean footerVisible)
Sets the visibility of the Footer in this Grid.
|
void |
setFrozenColumnCount(int numberOfColumns)
Sets the number of frozen columns in this grid.
|
void |
setHeaderRowHeight(double rowHeight)
Sets the height of a header row.
|
void |
setHeaderVisible(boolean headerVisible)
Sets the visibility of the Header in this Grid.
|
void |
setHeight(float height,
Sizeable.Unit unit)
Sets the height of the object.
|
void |
setHeightByRows(double rows)
Sets the number of rows that should be visible in Grid's body.
|
void |
setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.
|
protected void |
setPropertySet(PropertySet<T> propertySet)
Sets the property set to use for this grid.
|
protected void |
setReadOnly(boolean readOnly)
Sets the read-only status in the state of this
AbstractComponent. |
void |
setRowHeight(double rowHeight)
Sets the height of body, header and footer rows.
|
GridSelectionModel<T> |
setSelectionMode(Grid.SelectionMode selectionMode)
Sets the grid's selection mode.
|
protected void |
setSelectionModel(GridSelectionModel<T> model)
Sets the selection model for the grid.
|
void |
setSortOrder(GridSortOrderBuilder<T> builder)
Sets the sort order to use, given a
GridSortOrderBuilder. |
void |
setSortOrder(List<GridSortOrder<T>> order)
Sets the sort order to use.
|
void |
setStyleGenerator(StyleGenerator<T> styleGenerator)
Sets the style generator that is used for generating class names for rows
in this grid.
|
void |
sort(Grid.Column<T,?> column)
Sort this Grid in ascending order by a specified column.
|
void |
sort(Grid.Column<T,?> column,
SortDirection direction)
Sort this Grid in user-specified direction by a column.
|
void |
sort(String columnId)
Sort this Grid in ascending order by a specified column defined by id.
|
void |
sort(String columnId,
SortDirection direction)
Sort this Grid in a user-specified direction by a column defined by id.
|
static <BEAN> Grid<BEAN> |
withPropertySet(PropertySet<BEAN> propertySet)
Creates a grid using a custom
PropertySet implementation for
creating a default set of columns and for resolving property names with
addColumn(String) and
Grid.Column.setEditorComponent(HasValue). |
protected void |
writeData(org.jsoup.nodes.Element body,
DesignContext designContext)
Writes the data contained in this grid.
|
addDataGenerator, focus, getDataCommunicator, getItemCaptionGenerator, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setItemCaptionGenerator, setItemIconGenerator, setTabIndex, writeDesign, writeItem, writeItemsaddListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorsetItemsaddListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesignaddAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedpublic Grid()
Grid(Class),
to create a grid that automatically sets up columns based on the type of
presented data.Grid(Class),
withPropertySet(PropertySet)public Grid(Class<T> beanType)
Object.toString() renderer that is used
by addColumn(ValueProvider).beanType - the bean type to use, not nullGrid(),
withPropertySet(PropertySet)protected Grid(Class<T> beanType, DataCommunicator<T> dataCommunicator)
Object.toString() renderer that is used by
addColumn(ValueProvider).beanType - the bean type to use, not nulldataCommunicator - the data communicator to use, notnullprotected Grid(DataCommunicator<T> dataCommunicator)
dataCommunicator - the custom data communicator to setGrid(),
Grid(PropertySet, DataCommunicator)protected Grid(PropertySet<T> propertySet)
PropertySet implementation for
configuring the initial columns and resolving property names for
addColumn(String) and
Grid.Column.setEditorComponent(HasValue).propertySet - the property set implementation to use, not null.withPropertySet(PropertySet)protected Grid(PropertySet<T> propertySet, DataCommunicator<T> dataCommunicator)
PropertySet implementation and
custom data communicator.
Property set is used for configuring the initial columns and resolving
property names for addColumn(String) and
Grid.Column.setEditorComponent(HasValue).
propertySet - the property set implementation to use, not null.dataCommunicator - the data communicator to use, notnullwithPropertySet(PropertySet)public Grid(String caption)
Grid using the given caption.caption - the caption of the gridpublic Grid(String caption, DataProvider<T,?> dataProvider)
Grid using the given caption and
DataProvider.caption - the caption of the griddataProvider - the data provider, not nullpublic Grid(DataProvider<T,?> dataProvider)
Grid using the given DataProvider.dataProvider - the data provider, not nullpublic Grid(String caption, Collection<T> items)
Grid using the given caption and collection of
items.caption - the caption of the griditems - the data items to use, not public void beforeClientResponse(boolean initial)
ClientConnectorbeforeClientResponse in interface ClientConnectorbeforeClientResponse in class AbstractComponentinitial - true if the client-side connector will be created
and initialized after this method has been invoked.
false if there is already an initialized
client-side connector.protected void setPropertySet(PropertySet<T> propertySet)
This is only meant to be called from constructors and readDesign, at a stage where it does not matter if you throw away the editor.
propertySet - the property set to useprotected PropertySet<T> getPropertySet()
public static <BEAN> Grid<BEAN> withPropertySet(PropertySet<BEAN> propertySet)
PropertySet implementation for
creating a default set of columns and for resolving property names with
addColumn(String) and
Grid.Column.setEditorComponent(HasValue).
This functionality is provided as static method instead of as a public constructor in order to make it possible to use a custom property set without creating a subclass while still leaving the public constructors focused on the common use cases.
BEAN - the grid bean typepropertySet - the property set implementation to use, not null.nullGrid(),
Grid(Class)public Class<T> getBeanType()
The bean type is used to automatically set up a column added using a property name.
null if no bean type has been
definedpublic <V> void fireColumnVisibilityChangeEvent(Grid.Column<T,V> column, boolean hidden, boolean userOriginated)
Grid.ColumnVisibilityChangeEvent to all listeners.V - the column value typecolumn - the column that changed its visibilityhidden - true if the column was hidden, false if it
became visibleuserOriginated - true if the event was triggered by an UI interaction,
false otherwisepublic Grid.Column<T,?> addColumn(String propertyName)
TextRenderer. The value is converted to a String using
Object.toString(). The property name will be used as the
column id and the column caption will be set based on the property definition.
This method can only be used for a Grid created using
Grid(Class) or withPropertySet(PropertySet).
You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"
propertyName - the property name of the new column, not nullnullpublic Grid.Column<T,?> addColumn(String propertyName, AbstractRenderer<? super T,?> renderer)
column id and the
column caption will be set based on the
property definition.
This method can only be used for a Grid created using
Grid(Class) or withPropertySet(PropertySet).
You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"
propertyName - the property name of the new column, not nullrenderer - the renderer to use, not nullnullpublic Grid.Column<T,?> addColumn(String propertyName, AbstractRenderer<? super T,?> renderer, Grid.Column.NestedNullBehavior nestedNullBehavior)
column id and the
column caption will be set based on the
property definition.
This method can only be used for a Grid created using
Grid(Class) or withPropertySet(PropertySet).
You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"
propertyName - the property name of the new column, not nullrenderer - the renderer to use, not nullnestedNullBehavior - the behavior whennullpublic <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider)
Grid with a value provider. The
column will use a TextRenderer. The value is converted to a
String using Object.toString(). In-memory sorting will use the
natural ordering of elements if they are mutually comparable and
otherwise fall back to comparing the string representations of the
values.V - the column value typevalueProvider - the value providerpublic <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider, AbstractRenderer<? super T,? super V> renderer)
Grid with typed renderer and value
provider.V - the column value typevalueProvider - the value providerrenderer - the column value rendererAbstractRendererpublic <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,String> presentationProvider)
Grid with value provider and
presentation provider.
Note: The presentation type for this method is set to be
String. To use any custom renderer with the presentation provider, use
addColumn(ValueProvider, ValueProvider, AbstractRenderer).
V - the column value typevalueProvider - the value providerpresentationProvider - the value presentation provideraddColumn(ValueProvider, ValueProvider, AbstractRenderer)public <V,P> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, AbstractRenderer<? super T,? super P> renderer)
Grid with value provider, presentation
provider and typed renderer.
The presentation provider is a method that takes the value from the value provider, and maps that to a value that the renderer accepts. This feature can be used for storing a complex value in a column for editing, but providing a simplified presentation for the user when not editing.
V - the column value typeP - the column presentation typevalueProvider - the value providerpresentationProvider - the value presentation providerrenderer - the column value rendererAbstractRendererpublic <V extends Component> Grid.Column<T,V> addComponentColumn(ValueProvider<T,V> componentProvider)
This is a shorthand for #addColumn() with a
ComponentRenderer.
V - the column value type, extends componentcomponentProvider - a value provider that will return a component for the given
itemprotected <V,P> Grid.Column<T,V> createColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, AbstractRenderer<? super T,? super P> renderer)
V - the column value typeP - the column presentation typevalueProvider - the value providerpresentationProvider - the presentation providerrenderer - the rendererpublic void removeColumn(Grid.Column<T,?> column)
Grid.
Note: If you have Editor with binding in this Grid to this property, you
need to remove that using removeBinding method provided by Binder.column - the column to removeIllegalArgumentException - if the column is not a valid onepublic void removeColumn(String columnId)
columnId - the id of the column to remove, not nullremoveColumn(Column),
Grid.Column.setId(String)public void removeAllColumns()
public void recalculateColumnWidths()
In most cases Grid will know when column widths need to be recalculated but this method can be used to force recalculation in situations when grid does not recalculate automatically.
public void setDetailsGenerator(DetailsGenerator<T> generator)
generator - the generator for details componentspublic void setDetailsVisible(T item, boolean visible)
item - the item to show details forvisible - true if details component should be visible;
false if it should be hiddenpublic boolean isDetailsVisible(T item)
item - the item to show details fortrue if details component should be visible;
false if it should be hiddenpublic List<Grid.Column<T,?>> getColumns()
Grid.public Grid.Column<T,?> getColumn(String columnId)
Grid.Column of this grid by its identifying string.
When you use the Grid constructor with bean class, the columns are
initialised with columnId being the property name.columnId - the identifier of the column to getnull if there is no such columnGrid.Column.setId(String)public Iterator<Component> iterator()
The iterator is typically unmodifiable, and calls to
Iterator.remove() throw an exception.
Note that the order of the returned components it not specified.
iterator in interface HasComponentsiterator in interface Iterable<Component>public void setFrozenColumnCount(int numberOfColumns)
NOTE: this count includes hidden
columns in the count.
The default value is 0.
numberOfColumns - the number of columns that should be frozenIllegalArgumentException - if the column count is less than -1 or greater than the
number of visible columnspublic int getFrozenColumnCount()
NOTE: this count includes hidden
columns in the count.
setFrozenColumnCount(int)public void setHeightByRows(double rows)
HeightMode.ROW.rows - The height in terms of number of rows displayed in Grid's
body. If Grid doesn't contain enough rows, white space is
displayed instead.IllegalArgumentException - if rows is zero or lessIllegalArgumentException - if rows is infiniteIllegalArgumentException - if rows is NaNpublic double getHeightByRows()
getHeightMode() is HeightMode.ROW.setHeightByRows(double)public void setHeight(float height,
Sizeable.Unit unit)
Note: This method will set the height mode to be
HeightMode.CSS.
setHeight in interface SizeablesetHeight in class AbstractComponentheight - the height of the object.unit - the unit used for the width.setHeightMode(HeightMode)public void setHeightMode(HeightMode heightMode)
If HeightMode.CSS is given, Grid will respect the values given
via a setHeight-method, and behave as a traditional Component.
If HeightMode.ROW is given, Grid will make sure that the body
will display as many rows as getHeightByRows() defines.
Note: If headers/footers are inserted or removed, the widget
will resize itself to still display the required amount of rows in its
body. It also takes the horizontal scrollbar into account.
heightMode - the mode in to which Grid should be setpublic HeightMode getHeightMode()
HeightMode the Grid is in.
Defaults to HeightMode.CSS.
public void setRowHeight(double rowHeight)
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.
rowHeight - The height of a row in pixels or -1 for automatic calculationsetBodyRowHeight(double),
setHeaderRowHeight(double),
setFooterRowHeight(double)public void setBodyRowHeight(double rowHeight)
rowHeight - The height of a row in pixels or -1 for automatic calculationpublic void setHeaderRowHeight(double rowHeight)
rowHeight - The height of a row in pixels or -1 for automatic calculationpublic void setFooterRowHeight(double rowHeight)
rowHeight - The height of a row in pixels or -1 for automatic calculation@Deprecated public double getRowHeight()
getBodyRowHeight(),
getHeaderRowHeight(),
getFooterRowHeight()public double getBodyRowHeight()
public double getHeaderRowHeight()
public double getFooterRowHeight()
public void setStyleGenerator(StyleGenerator<T> styleGenerator)
styleGenerator - the row style generator to set, not nullNullPointerException - if styleGenerator is nullStyleGeneratorpublic StyleGenerator<T> getStyleGenerator()
StyleGeneratorpublic void setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
ContentMode.PREFORMATTED content
mode.descriptionGenerator - the row description generator to set, or null to
remove a previously set generatorsetDescriptionGenerator(DescriptionGenerator, ContentMode)public void setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator, ContentMode contentMode)
descriptionGenerator - the row description generator to set, or null to
remove a previously set generatorcontentMode - the content mode for row tooltipssetDescriptionGenerator(DescriptionGenerator)public DescriptionGenerator<T> getDescriptionGenerator()
null if no
generator is setpublic HeaderRow getHeaderRow(int index)
index - the index of the row, where the topmost row has index zeroIndexOutOfBoundsException - if rowIndex < 0 || rowIndex >= getHeaderRowCount()public int getHeaderRowCount()
public HeaderRow addHeaderRowAt(int index)
getHeaderRowCount() appends the row
at the bottom of the header.index - the index at which to insert the row, where the topmost row
has index zeroIndexOutOfBoundsException - if rowIndex < 0 || rowIndex > getHeaderRowCount()appendHeaderRow(),
prependHeaderRow(),
removeHeaderRow(HeaderRow),
removeHeaderRow(int)public HeaderRow appendHeaderRow()
prependHeaderRow(),
addHeaderRowAt(int),
removeHeaderRow(HeaderRow),
removeHeaderRow(int)public HeaderRow prependHeaderRow()
appendHeaderRow(),
addHeaderRowAt(int),
removeHeaderRow(HeaderRow),
removeHeaderRow(int)public void removeHeaderRow(HeaderRow row)
row - the header row to be removed, not nullIllegalArgumentException - if the header does not contain the rowremoveHeaderRow(int),
addHeaderRowAt(int),
appendHeaderRow(),
prependHeaderRow()public void removeHeaderRow(int index)
index - the index of the row to remove, where the topmost row has
index zeroIndexOutOfBoundsException - if index < 0 || index >= getHeaderRowCount()removeHeaderRow(HeaderRow),
addHeaderRowAt(int),
appendHeaderRow(),
prependHeaderRow()public void setHeaderVisible(boolean headerVisible)
headerVisible - true if visible; false if notpublic boolean isHeaderVisible()
true if visible; false if notpublic HeaderRow getDefaultHeaderRow()
setDefaultHeaderRow(HeaderRow)public void setDefaultHeaderRow(HeaderRow row)
row - the new default row, or null for no default rowIllegalArgumentException - if the header does not contain the rowprotected Header getHeader()
public FooterRow getFooterRow(int index)
index - the index of the row, where the topmost row has index zeroIndexOutOfBoundsException - if rowIndex < 0 || rowIndex >= getFooterRowCount()public int getFooterRowCount()
public FooterRow addFooterRowAt(int index)
getFooterRowCount() appends the row
at the bottom of the footer.index - the index at which to insert the row, where the topmost row
has index zeroIndexOutOfBoundsException - if rowIndex < 0 || rowIndex > getFooterRowCount()appendFooterRow(),
prependFooterRow(),
removeFooterRow(FooterRow),
removeFooterRow(int)public FooterRow appendFooterRow()
prependFooterRow(),
addFooterRowAt(int),
removeFooterRow(FooterRow),
removeFooterRow(int)public FooterRow prependFooterRow()
appendFooterRow(),
addFooterRowAt(int),
removeFooterRow(FooterRow),
removeFooterRow(int)public void removeFooterRow(FooterRow row)
row - the footer row to be removed, not nullIllegalArgumentException - if the footer does not contain the rowremoveFooterRow(int),
addFooterRowAt(int),
appendFooterRow(),
prependFooterRow()public void removeFooterRow(int index)
index - the index of the row to remove, where the topmost row has
index zeroIndexOutOfBoundsException - if index < 0 || index >= getFooterRowCount()removeFooterRow(FooterRow),
addFooterRowAt(int),
appendFooterRow(),
prependFooterRow()public void setFooterVisible(boolean footerVisible)
footerVisible - true if visible; false if notpublic boolean isFooterVisible()
true if visible; false if notprotected Footer getFooter()
public Registration addColumnReorderListener(ColumnReorderListener listener)
listener - the listener to register, not nullpublic Registration addColumnResizeListener(ColumnResizeListener listener)
listener - the listener to register, not nullpublic Registration addItemClickListener(ItemClickListener<? super T> listener)
Grid is clicked.listener - the item click listener, not nulladdContextClickListener(com.vaadin.event.ContextClickEvent.ContextClickListener)public Registration addContextClickListener(ContextClickEvent.ContextClickListener listener)
addContextClickListener in interface ContextClickEvent.ContextClickNotifieraddContextClickListener in class AbstractComponentlistener - the context click listener to add, not null actual event
provided to the listener is Grid.GridContextClickEventaddItemClickListener(com.vaadin.ui.components.grid.ItemClickListener<? super T>),
Registrationpublic Registration addColumnVisibilityChangeListener(ColumnVisibilityChangeListener listener)
listener - the listener to register, not nullpublic boolean isColumnReorderingAllowed()
false.public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
false.columnReorderingAllowed - specifies whether column reordering is allowedpublic void setColumns(String... columnIds)
Grid created using Grid(Class) or
withPropertySet(PropertySet).columnIds - the column ids to setGrid.Column.setId(String)public void setColumns(Collection<String> columnIds)
Grid created using Grid(Class) or
withPropertySet(PropertySet).columnIds - the column ids to setGrid.Column.setId(String),
setColumns(String...)public void setColumnOrder(Grid.Column<T,?>... columns)
columns - the columns in the order they should bepublic void setColumnOrder(String... columnIds)
columnIds - the column ids in the order they should beGrid.Column.setId(String)public GridSelectionModel<T> getSelectionModel()
public GridSingleSelect<T> asSingleSelect()
Binder.
Throws IllegalStateException if the grid is not using a
SingleSelectionModel.
IllegalStateException - if not using a single selection modelpublic Editor<T> getEditor()
Editor for this grid.public GridMultiSelect<T> asMultiSelect()
Binder.
Throws IllegalStateException if the grid is not using a
MultiSelectionModel.
IllegalStateException - if not using a multiselection modelprotected void setSelectionModel(GridSelectionModel<T> model)
This method is for setting a custom selection model, and is
protected because setSelectionMode(SelectionMode) should
be used for easy switching between built-in selection models.
The default selection model is SingleSelectionModelImpl.
To use a custom selection model, you can e.g. extend the grid call this method with your custom selection model.
model - the selection model to use, not nullsetSelectionMode(SelectionMode)public GridSelectionModel<T> setSelectionMode(Grid.SelectionMode selectionMode)
The built-in selection models are:
Grid.SelectionMode.SINGLE -> SingleSelectionModelImpl,
the default modelGrid.SelectionMode.MULTI -> MultiSelectionModelImpl, with
checkboxes in the first column for selectionGrid.SelectionMode.NONE -> NoSelectionModel, preventing
selection
To use your custom selection model, you can use
setSelectionModel(GridSelectionModel), see existing selection
model implementations for example.
selectionMode - the selection mode to switch to, not nullGrid.SelectionMode,
GridSelectionModel,
setSelectionModel(GridSelectionModel)public Set<T> getSelectedItems()
getSelectionModel(),
GridSelectionModelpublic void select(T item)
item - the item to select, not nullgetSelectionModel(),
GridSelectionModelpublic void deselect(T item)
item - the item to deselect, not nullgetSelectionModel(),
GridSelectionModelpublic void deselectAll()
getSelectionModel(),
GridSelectionModelpublic Registration addSelectionListener(SelectionListener<T> listener) throws UnsupportedOperationException
NOTE: If selection mode is switched with
setSelectionMode(SelectionMode), then this listener is not
triggered anymore when selection changes!
This is a shorthand for
grid.getSelectionModel().addSelectionListener(). To get more
detailed selection events, use getSelectionModel() and either
SingleSelectionModel.addSingleSelectionListener(SingleSelectionListener)
or
MultiSelectionModel.addMultiSelectionListener(MultiSelectionListener)
depending on the used selection mode.
listener - the listener to addUnsupportedOperationException - if selection has been disabled with
Grid.SelectionMode.NONEpublic void sort(Grid.Column<T,?> column)
column - a column to sort againstpublic void sort(Grid.Column<T,?> column, SortDirection direction)
column - a column to sort againstdirection - a sort order value (ascending/descending)public void sort(String columnId)
columnId - the id of the column to sort againstGrid.Column.setId(String)public void sort(String columnId, SortDirection direction)
columnId - the id of the column to sort againstdirection - a sort order value (ascending/descending)Grid.Column.setId(String)public void clearSortOrder()
public void setSortOrder(List<GridSortOrder<T>> order)
order - a sort order list.IllegalArgumentException - if order is nullpublic void setSortOrder(GridSortOrderBuilder<T> builder)
GridSortOrderBuilder.
Shorthand for setSortOrder(builder.build()).builder - the sort builder to retrieve the sort order fromNullPointerException - if builder is nullGridSortOrderBuilderpublic Registration addSortListener(SortEvent.SortListener<GridSortOrder<T>> listener)
addSortListener in interface SortEvent.SortNotifier<GridSortOrder<T>>listener - the sort order change listener to addpublic List<GridSortOrder<T>> getSortOrder()
public void scrollTo(int row)
throws IllegalArgumentException
ScrollDestination.ANY.
If the item has an open details row, its size will also be taken into account.
row - zero based index of the item to scroll to in the current view.IllegalArgumentException - if the provided row is outside the item rangepublic void scrollTo(int row,
ScrollDestination destination)
If the item has an open details row, its size will also be taken into account.
row - zero based index of the item to scroll to in the current view.destination - value specifying desired position of scrolled-to row, not
nullIllegalArgumentException - if the provided row is outside the item rangepublic void scrollToStart()
public void scrollToEnd()
protected GridState getState()
AbstractComponentgetState in class AbstractListing<T>protected GridState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractListing<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public void setColumnResizeMode(ColumnResizeMode mode)
ColumnResizeMode.ANIMATED.mode - a ColumnResizeMode valuepublic ColumnResizeMode getColumnResizeMode()
ColumnResizeMode.ANIMATED.protected Editor<T> createEditor()
Grid.AbstractGridExtension, it will be
automatically added to DataCommunicator.protected void readItems(org.jsoup.nodes.Element design,
DesignContext context)
AbstractListingdesign.readItems in class AbstractListing<T>design - The element to obtain the state fromcontext - The DesignContext instance used for parsing the designpublic DataProvider<T,?> getDataProvider()
HasItemsgetDataProvider in interface HasItems<T>public void setDataProvider(DataProvider<T,?> dataProvider)
HasDataProvidersetDataProvider in interface HasDataProvider<T>dataProvider - the data provider, not nullpublic void setDataProvider(Grid.FetchItemsCallback<T> fetchItems, SerializableSupplier<Integer> sizeCallback)
This method is a shorthand for making a CallbackDataProvider that
handles a partial Query object.
fetchItems - a callback for fetching itemssizeCallback - a callback for getting the count of itemsCallbackDataProvider,
setDataProvider(DataProvider)protected void doReadDesign(org.jsoup.nodes.Element design,
DesignContext context)
AbstractListing
This method is separated from AbstractListing.readDesign(Element, DesignContext)
to be overridable in subclasses that need to replace this, but still must
be able to call super.readDesign(...).
doReadDesign in class AbstractListing<T>design - The element to obtain the state fromcontext - The DesignContext instance used for parsing the designAbstractListing.doWriteDesign(Element, DesignContext)protected void setBeanType(String beanTypeClassName)
This method is responsible also for setting or updating the property set so that it matches the given bean type.
Protected mostly for Designer needs, typically should not be overridden or even called.
beanTypeClassName - the fully qualified class name of the bean typeprotected void setBeanType(Class<T> beanType)
This method is responsible also for setting or updating the property set so that it matches the given bean type.
Protected mostly for Designer needs, typically should not be overridden or even called.
beanType - the bean type classprotected void doWriteDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
AbstractListing
This method is separated from
AbstractListing.writeDesign(Element, DesignContext) to be overridable in
subclasses that need to replace this, but still must be able to call
super.writeDesign(...).
doWriteDesign in class AbstractListing<T>design - The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext - The DesignContext instance used for writing the designAbstractListing.doReadDesign(Element, DesignContext)protected T deserializeDeclarativeRepresentation(String item)
AbstractListing
Default implementation is able to handle only String as an item
type. There will be a ClassCastException if T is not a
String.
deserializeDeclarativeRepresentation in class AbstractListing<T>item - string to deserializeAbstractListing.serializeDeclarativeRepresentation(Object)protected boolean isReadOnly()
AbstractComponentAbstractComponent. This method should be made public in
Components that implement HasValue.isReadOnly in class AbstractComponenttrue if state has read-only on; false if notAbstractComponent.setReadOnly(boolean)protected void setReadOnly(boolean readOnly)
AbstractComponentAbstractComponent.
This method should be made public in Components that
implement HasValue.setReadOnly in class AbstractComponentreadOnly - a boolean value specifying whether the component is put
read-only mode or notprotected void readData(org.jsoup.nodes.Element body,
List<com.vaadin.ui.DeclarativeValueProvider<T>> providers)
DeclarativeValueProviders.
Each member in the list of value providers corresponds to a column in the
grid.body - the element to read data fromproviders - list of DeclarativeValueProviders to store the data of
each column toprotected void writeData(org.jsoup.nodes.Element body,
DesignContext designContext)
DesignContext.shouldWriteData(Component) returns true for
the grid that is being written.body - the body element to write the declarative representation of
data todesignContext - the design contextprotected void setColumnId(String id, Grid.Column<T,?> column)
column - the columnid - the user-defined identifierGrid.Column.setId(String)protected Collection<String> getCustomAttributes()
AbstractComponentAbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. Typically these
are handled in a custom way in the overridden versions of the above
methodsgetCustomAttributes in class AbstractComponentprotected Grid.Column<T,?> getColumnByInternalId(String columnId)
columnId - the internal id of columnprotected String getInternalIdForColumn(Grid.Column<T,?> column)
column - the columnprotected SerializableComparator<T> createSortingComparator()
protected void internalSetDataProvider(DataProvider<T,?> dataProvider)
internalSetDataProvider in class AbstractListing<T>Copyright © 2022 Vaadin Ltd. All rights reserved.