Class Grid<T>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractListing<T>
-
- com.vaadin.ui.Grid<T>
-
- Type Parameters:
T- the grid bean type
- All Implemented Interfaces:
HasDataProvider<T>,HasItems<T>,ContextClickEvent.ContextClickNotifier,MethodEventSource,SortEvent.SortNotifier<GridSortOrder<T>>,ClientConnector,Sizeable,Connector,Component,Component.Focusable,HasComponents,Serializable,Iterable<Component>
- Direct Known Subclasses:
TreeGrid
public class Grid<T> extends AbstractListing<T> implements HasComponents, HasDataProvider<T>, SortEvent.SortNotifier<GridSortOrder<T>>
A grid component for displaying tabular data.- Since:
- 8.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrid.AbstractGridExtension<T>A helper base class for creating extensions for the Grid component.static classGrid.Column<T,V>This extension manages the configuration and data communication for a Column inside of a Grid component.static classGrid.ColumnReorderEventAn event that is fired when the columns are reordered.static classGrid.ColumnResizeEventAn event that is fired when a column is resized, either programmatically or by the user.static classGrid.ColumnVisibilityChangeEventAn event that is fired when a column's visibility changes.static classGrid.DetailsManager<T>Class for managing visible details rows.static interfaceGrid.FetchItemsCallback<T>A callback method for fetching items.static classGrid.GridContextClickEvent<T>ContextClickEvent for the Grid Component.static classGrid.ItemClick<T>An event fired when an item in the Grid has been clicked.static classGrid.SelectionModeSelection mode representing the built-in selection models in grid.-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractListing
AbstractListing.AbstractListingExtension<T>
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Modifier Constructor Description Grid()Creates a new grid without support for creating columns based on property names.protectedGrid(PropertySet<T> propertySet)Creates a grid using a customPropertySetimplementation for configuring the initial columns and resolving property names foraddColumn(String)andGrid.Column.setEditorComponent(HasValue).protectedGrid(PropertySet<T> propertySet, DataCommunicator<T> dataCommunicator)Creates a grid using a customPropertySetimplementation and custom data communicator.protectedGrid(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 newGridusing the givenDataProvider.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.protectedGrid(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.Grid(String caption)Creates a newGridusing the given caption.Grid(String caption, DataProvider<T,?> dataProvider)Creates a newGridusing the given caption andDataProvider.Grid(String caption, Collection<T> items)Creates a newGridusing the given caption and collection of items.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <V> Grid.Column<T,V>addColumn(ValueProvider<T,V> valueProvider)Adds a new text column to thisGridwith a value provider.<V> Grid.Column<T,V>addColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,String> presentationProvider)Adds a new column to thisGridwith value provider and presentation 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 thisGridwith value provider, presentation provider and typed renderer.<V> Grid.Column<T,V>addColumn(ValueProvider<T,V> valueProvider, AbstractRenderer<? super T,? super V> renderer)Adds a new column to thisGridwith typed renderer and value provider.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.RegistrationaddColumnReorderListener(ColumnReorderListener listener)Registers a new column reorder listener.RegistrationaddColumnResizeListener(ColumnResizeListener listener)Registers a new column resize listener.RegistrationaddColumnVisibilityChangeListener(ColumnVisibilityChangeListener listener)Registers a new column visibility change listener.<V extends Component>
Grid.Column<T,V>addComponentColumn(ValueProvider<T,V> componentProvider)Adds a column that shows components.RegistrationaddContextClickListener(ContextClickEvent.ContextClickListener listener)Adds a context click listener that gets notified when a context click happens.FooterRowaddFooterRowAt(int index)Inserts a new row at the given position to the footer section.HeaderRowaddHeaderRowAt(int index)Inserts a new row at the given position to the header section.RegistrationaddItemClickListener(ItemClickListener<? super T> listener)Adds an item click listener.RegistrationaddSelectionListener(SelectionListener<T> listener)Adds a selection listener to the current selection model.RegistrationaddSortListener(SortEvent.SortListener<GridSortOrder<T>> listener)Adds a sort order change listener that gets notified when the sort order changes.FooterRowappendFooterRow()Adds a new row at the bottom of the footer section.HeaderRowappendHeaderRow()Adds a new row at the bottom of the header section.GridMultiSelect<T>asMultiSelect()User this grid as a multiselect inBinder.GridSingleSelect<T>asSingleSelect()Use this grid as a single select inBinder.voidbeforeClientResponse(boolean initial)Called before the shared state and RPC invocations are sent to the client.voidclearSortOrder()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.voiddeselect(T item)This method is a shorthand that delegates to the currently set selection model.voiddeselectAll()This method is a shorthand that delegates to the currently set selection model.protected TdeserializeDeclarativeRepresentation(String item)Deserializes a string to a data item.protected voiddoReadDesign(org.jsoup.nodes.Element design, DesignContext context)Reads the listing specific state from the given design.protected voiddoWriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Writes listing specific state into the given design.<V> voidfireColumnVisibilityChangeEvent(Grid.Column<T,V> column, boolean hidden, boolean userOriginated)Sends aGrid.ColumnVisibilityChangeEventto all listeners.Class<T>getBeanType()Gets the bean type used by this grid.doublegetBodyRowHeight()Returns the current body row height. -1 if row height is in automatic calculation mode.Grid.Column<T,?>getColumn(String columnId)Gets aGrid.Columnof this grid by its identifying string.protected Grid.Column<T,?>getColumnByInternalId(String columnId)Returns a column identified by its internal id.ColumnResizeModegetColumnResizeMode()Returns the current column resize mode.List<Grid.Column<T,?>>getColumns()Gets an unmodifiable collection of all columns currently in thisGrid.protected Collection<String>getCustomAttributes()Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods.DataProvider<T,?>getDataProvider()Returns the source of data items used by this listing.HeaderRowgetDefaultHeaderRow()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 theEditorfor this grid.protected FootergetFooter()Returns the footer section of this grid.FooterRowgetFooterRow(int index)Returns the footer row at the given index.intgetFooterRowCount()Gets the number of rows in the footer section.doublegetFooterRowHeight()Returns the current footer row height. -1 if row height is in automatic calculation mode.intgetFrozenColumnCount()Gets the number of frozen columns in this grid. 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. -1 means that not even the selection column is frozen.protected HeadergetHeader()Returns the header section of this grid.HeaderRowgetHeaderRow(int index)Returns the header row at the given index.intgetHeaderRowCount()Gets the number of rows in the header section.doublegetHeaderRowHeight()Returns the current header row height. -1 if row height is in automatic calculation mode.doublegetHeightByRows()Gets the amount of rows in Grid's body that are shown, whilegetHeightMode()isHeightMode.ROW.HeightModegetHeightMode()Returns the currentHeightModethe Grid is in.protected StringgetInternalIdForColumn(Grid.Column<T,?> column)Returns the internal id for given column.protected PropertySet<T>getPropertySet()Returns the property set used by this grid.doublegetRowHeight()Deprecated.replaced by three separate row height controlsSet<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.GridConstants.SidebarColumnOrdergetSidebarColumnOrder()Get the current sidebar column order.List<GridSortOrder<T>>getSortOrder()Get the current sort order list.protected GridStategetState()Returns the shared state bean with information to be sent from the server to the client.protected GridStategetState(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 voidinternalSetDataProvider(DataProvider<T,?> dataProvider)booleanisAccessibleNavigation()Check whether accessible navigation mode is on.booleanisColumnReorderingAllowed()Returns whether column reordering is allowed.booleanisDetailsVisible(T item)Returns the visibility of details component for given item.booleanisFooterVisible()Gets the visibility of the Footer in this Grid.booleanisHeaderVisible()Gets the visibility of the Header in this Grid.booleanisReadOnly()Returns the read-only status from the state of thisAbstractComponent.Iterator<Component>iterator()Gets an iterator to the collection of contained components.FooterRowprependFooterRow()Adds a new row at the top of the footer section.HeaderRowprependHeaderRow()Adds a new row at the top of the header section.protected voidreadData(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 givenDeclarativeValueProviders.protected voidreadItems(org.jsoup.nodes.Element design, DesignContext context)Reads the data source items from thedesign.voidrecalculateColumnWidths()Requests that the column widths should be recalculated.voidremoveAllColumns()Removes all columns from this Grid.voidremoveColumn(Grid.Column<T,?> column)Removes the given column from thisGrid.voidremoveColumn(String columnId)Removes the column with the given column id.voidremoveFooterRow(int index)Removes the row at the given position from the footer section.voidremoveFooterRow(FooterRow row)Removes the given row from the footer section.voidremoveHeaderRow(int index)Removes the row at the given position from the header section.voidremoveHeaderRow(HeaderRow row)Removes the given row from the header section.voidscrollTo(int row)Scrolls to a certain item, usingScrollDestination.ANY.voidscrollTo(int row, ScrollDestination destination)Scrolls to a certain item, using user-specified scroll destination.voidscrollToColumn(Grid.Column<T,?> column)Scrolls to the given column, usingScrollDestination.ANY.voidscrollToColumn(Grid.Column<T,?> column, ScrollDestination destination)Scrolls to the given column, using the given scroll destination.voidscrollToColumn(String columnId)Scrolls to the given column, usingScrollDestination.ANY.voidscrollToColumn(String columnId, ScrollDestination destination)Scrolls to the given column, using the given scroll destination.voidscrollToEnd()Scrolls to the end of the last data row.voidscrollToStart()Scrolls to the beginning of the first data row.voidselect(T item)This method is a shorthand that delegates to the currently set selection model.voidsetAccessibleNavigation(boolean accessibleNavigation)Sets whether accessible navigation is enabled for the grid.protected voidsetBeanType(Class<T> beanType)Sets the bean type to use for property mapping.protected voidsetBeanType(String beanTypeClassName)Sets the bean type to use for property mapping.voidsetBodyRowHeight(double rowHeight)Sets the height of a body row.protected voidsetColumnId(String id, Grid.Column<T,?> column)Sets a user-defined identifier for given column.voidsetColumnOrder(Grid.Column<T,?>... columns)Sets a new column order for the grid.voidsetColumnOrder(String... columnIds)Sets a new column order for the grid based on their column ids.voidsetColumnReorderingAllowed(boolean columnReorderingAllowed)Sets whether or not column reordering is allowed.voidsetColumnResizeMode(ColumnResizeMode mode)Sets the column resize mode to use.voidsetColumns(String... columnIds)Sets the columns and their order based on their column ids.voidsetColumns(Collection<String> columnIds)Sets the columns and their order based on their column ids provided that collection supports preserving of the order.voidsetDataProvider(DataProvider<T,?> dataProvider)Sets the data provider for this listing.voidsetDataProvider(Grid.FetchItemsCallback<T> fetchItems, SerializableSupplier<Integer> sizeCallback)Sets a CallbackDataProvider using the given fetch items callback and a size callback.voidsetDefaultHeaderRow(HeaderRow row)Sets the default row of the header.voidsetDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)Sets the description generator that is used for generating descriptions for rows.voidsetDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator, ContentMode contentMode)Sets the description generator that is used for generating descriptions for rows.voidsetDetailsGenerator(DetailsGenerator<T> generator)Sets the details component generator.voidsetDetailsVisible(T item, boolean visible)Sets the visibility of details component for given item.voidsetFooterRowHeight(double rowHeight)Sets the height of a footer row.voidsetFooterVisible(boolean footerVisible)Sets the visibility of the Footer in this Grid.voidsetFrozenColumnCount(int numberOfColumns)Sets the number of frozen columns in this grid.voidsetHeaderRowHeight(double rowHeight)Sets the height of a header row.voidsetHeaderVisible(boolean headerVisible)Sets the visibility of the Header in this Grid.voidsetHeight(float height, Sizeable.Unit unit)Sets the height of the object.voidsetHeightByRows(double rows)Sets the number of rows that should be visible in Grid's body.voidsetHeightMode(HeightMode heightMode)Defines the mode in which the Grid widget's height is calculated.protected voidsetPropertySet(PropertySet<T> propertySet)Sets the property set to use for this grid.voidsetReadOnly(boolean readOnly)Sets the read-only status in the state of thisAbstractComponent.voidsetRowHeight(double rowHeight)Sets the height of body, header and footer rows.GridSelectionModel<T>setSelectionMode(Grid.SelectionMode selectionMode)Sets the grid's selection mode.protected voidsetSelectionModel(GridSelectionModel<T> model)Sets the selection model for the grid.voidsetSidebarColumnOrder(GridConstants.SidebarColumnOrder order)Set the order of the columns visible in the sidebar menu.voidsetSortOrder(GridSortOrderBuilder<T> builder)Sets the sort order to use, given aGridSortOrderBuilder.voidsetSortOrder(List<GridSortOrder<T>> order)Sets the sort order to use.voidsetStyleGenerator(StyleGenerator<T> styleGenerator)Sets the style generator that is used for generating class names for rows in this grid.voidsort(Grid.Column<T,?> column)Sort this Grid in ascending order by a specified column.voidsort(Grid.Column<T,?> column, SortDirection direction)Sort this Grid in user-specified direction by a column.voidsort(String columnId)Sort this Grid in ascending order by a specified column defined by id.voidsort(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 customPropertySetimplementation for creating a default set of columns and for resolving property names withaddColumn(String)andGrid.Column.setEditorComponent(HasValue).protected voidwriteData(org.jsoup.nodes.Element body, DesignContext designContext)Writes the data contained in this grid.-
Methods inherited from class com.vaadin.ui.AbstractListing
addDataGenerator, focus, getDataCommunicator, getItemCaptionGenerator, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setItemCaptionGenerator, setItemIconGenerator, setTabIndex, writeDesign, writeItem, writeItems
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, 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, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, 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, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, 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, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasDataProvider
setItems
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Constructor Detail
-
Grid
public Grid()
Creates a new grid without support for creating columns based on property names. Use an alternative constructor, such asGrid(Class), to create a grid that automatically sets up columns based on the type of presented data.- See Also:
Grid(Class),withPropertySet(PropertySet)
-
Grid
public 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. All columns will be configured using the sameObject.toString()renderer that is used byaddColumn(ValueProvider).- Parameters:
beanType- the bean type to use, notnull- See Also:
Grid(),withPropertySet(PropertySet)
-
Grid
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. All columns will be configured using the sameObject.toString()renderer that is used byaddColumn(ValueProvider).- Parameters:
beanType- the bean type to use, notnulldataCommunicator- the data communicator to use, notnull- Since:
- 8.0.7
-
Grid
protected Grid(DataCommunicator<T> dataCommunicator)
Creates a new grid with the given data communicator and without support for creating columns based on property names.- Parameters:
dataCommunicator- the custom data communicator to set- Since:
- 8.0.7
- See Also:
Grid(),Grid(PropertySet, DataCommunicator)
-
Grid
protected Grid(PropertySet<T> propertySet)
Creates a grid using a customPropertySetimplementation for configuring the initial columns and resolving property names foraddColumn(String)andGrid.Column.setEditorComponent(HasValue).- Parameters:
propertySet- the property set implementation to use, notnull.- See Also:
withPropertySet(PropertySet)
-
Grid
protected Grid(PropertySet<T> propertySet, DataCommunicator<T> dataCommunicator)
Creates a grid using a customPropertySetimplementation and custom data communicator.Property set is used for configuring the initial columns and resolving property names for
addColumn(String)andGrid.Column.setEditorComponent(HasValue).- Parameters:
propertySet- the property set implementation to use, notnull.dataCommunicator- the data communicator to use, notnull- Since:
- 8.0.7
- See Also:
withPropertySet(PropertySet)
-
Grid
public Grid(String caption)
Creates a newGridusing the given caption.- Parameters:
caption- the caption of the grid
-
Grid
public Grid(String caption, DataProvider<T,?> dataProvider)
Creates a newGridusing the given caption andDataProvider.- Parameters:
caption- the caption of the griddataProvider- the data provider, notnull
-
Grid
public Grid(DataProvider<T,?> dataProvider)
Creates a newGridusing the givenDataProvider.- Parameters:
dataProvider- the data provider, notnull
-
Grid
public Grid(String caption, Collection<T> items)
Creates a newGridusing the given caption and collection of items.- Parameters:
caption- the caption of the griditems- the data items to use, notnull
-
-
Method Detail
-
beforeClientResponse
public void beforeClientResponse(boolean initial)
Description copied from interface:ClientConnectorCalled before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.- Specified by:
beforeClientResponsein interfaceClientConnector- Overrides:
beforeClientResponsein classAbstractComponent- Parameters:
initial-trueif the client-side connector will be created and initialized after this method has been invoked.falseif there is already an initialized client-side connector.
-
setPropertySet
protected void setPropertySet(PropertySet<T> propertySet)
Sets the property set to use for this grid. Does not create or update columns in any way but will delete and re-create the editor.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.
- Parameters:
propertySet- the property set to use- Since:
- 8.0.3
-
getPropertySet
protected PropertySet<T> getPropertySet()
Returns the property set used by this grid.- Returns:
- propertySet the property set to return
- Since:
- 8.4
-
withPropertySet
public static <BEAN> Grid<BEAN> withPropertySet(PropertySet<BEAN> propertySet)
Creates a grid using a customPropertySetimplementation for creating a default set of columns and for resolving property names withaddColumn(String)andGrid.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.
- Type Parameters:
BEAN- the grid bean type- Parameters:
propertySet- the property set implementation to use, notnull.- Returns:
- a new grid using the provided property set, not
null - See Also:
Grid(),Grid(Class)
-
getBeanType
public Class<T> getBeanType()
Gets the bean type used by this grid.The bean type is used to automatically set up a column added using a property name.
- Returns:
- the used bean type or
nullif no bean type has been defined - Since:
- 8.0.3
-
fireColumnVisibilityChangeEvent
public <V> void fireColumnVisibilityChangeEvent(Grid.Column<T,V> column, boolean hidden, boolean userOriginated)
Sends aGrid.ColumnVisibilityChangeEventto all listeners.- Type Parameters:
V- the column value type- Parameters:
column- the column that changed its visibilityhidden-trueif the column was hidden,falseif it became visibleuserOriginated-trueif the event was triggered by an UI interaction,falseotherwise
-
addColumn
public Grid.Column<T,?> addColumn(String propertyName)
Adds a new column with the given property name. The column will use aTextRenderer. The value is converted to a String usingObject.toString(). The property name will be used as thecolumn idand thecolumn captionwill be set based on the property definition.This method can only be used for a
Gridcreated usingGrid(Class)orwithPropertySet(PropertySet).You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"- Parameters:
propertyName- the property name of the new column, notnull- Returns:
- the newly added column, not
null
-
addColumn
public Grid.Column<T,?> addColumn(String propertyName, AbstractRenderer<? super T,?> renderer)
Adds a new column with the given property name and renderer. The property name will be used as thecolumn idand thecolumn captionwill be set based on the property definition.This method can only be used for a
Gridcreated usingGrid(Class)orwithPropertySet(PropertySet).You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"- Parameters:
propertyName- the property name of the new column, notnullrenderer- the renderer to use, notnull- Returns:
- the newly added column, not
null
-
addColumn
public 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. The property name will be used as thecolumn idand thecolumn captionwill be set based on the property definition.This method can only be used for a
Gridcreated usingGrid(Class)orwithPropertySet(PropertySet).You can add columns for nested properties with dot notation, eg.
"property.nestedProperty"- Parameters:
propertyName- the property name of the new column, notnullrenderer- the renderer to use, notnullnestedNullBehavior- the behavior when- Returns:
- the newly added column, not
null - Since:
- 8.8
-
addColumn
public <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider)
Adds a new text column to thisGridwith a value provider. The column will use aTextRenderer. The value is converted to a String usingObject.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.- Type Parameters:
V- the column value type- Parameters:
valueProvider- the value provider- Returns:
- the new column
-
addColumn
public <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider, AbstractRenderer<? super T,? super V> renderer)
Adds a new column to thisGridwith typed renderer and value provider.- Type Parameters:
V- the column value type- Parameters:
valueProvider- the value providerrenderer- the column value renderer- Returns:
- the new column
- See Also:
AbstractRenderer
-
addColumn
public <V> Grid.Column<T,V> addColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,String> presentationProvider)
Adds a new column to thisGridwith 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).- Type Parameters:
V- the column value type- Parameters:
valueProvider- the value providerpresentationProvider- the value presentation provider- Returns:
- the new column
- Since:
- 8.1
- See Also:
addColumn(ValueProvider, ValueProvider, AbstractRenderer)
-
addColumn
public <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 thisGridwith 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.
- Type Parameters:
V- the column value typeP- the column presentation type- Parameters:
valueProvider- the value providerpresentationProvider- the value presentation providerrenderer- the column value renderer- Returns:
- the new column
- Since:
- 8.1
- See Also:
AbstractRenderer
-
addComponentColumn
public <V extends Component> Grid.Column<T,V> addComponentColumn(ValueProvider<T,V> componentProvider)
Adds a column that shows components.This is a shorthand for
addColumn(String)and its variants with aComponentRenderer.- Type Parameters:
V- the column value type, extends component- Parameters:
componentProvider- a value provider that will return a component for the given item- Returns:
- the new column
- Since:
- 8.1
-
createColumn
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.- Type Parameters:
V- the column value typeP- the column presentation type- Parameters:
valueProvider- the value providerpresentationProvider- the presentation providerrenderer- the renderer- Returns:
- a new column instance
- Since:
- 8.1
-
removeColumn
public void removeColumn(Grid.Column<T,?> column)
Removes the given column from thisGrid. Note: If you have Editor with binding in this Grid to this property, you need to remove that using removeBinding method provided by Binder.- Parameters:
column- the column to remove- Throws:
IllegalArgumentException- if the column is not a valid one
-
removeColumn
public void removeColumn(String columnId)
Removes the column with the given column id.- Parameters:
columnId- the id of the column to remove, notnull- See Also:
removeColumn(Column),Grid.Column.setId(String)
-
removeAllColumns
public void removeAllColumns()
Removes all columns from this Grid.- Since:
- 8.0.2
-
setSidebarColumnOrder
public void setSidebarColumnOrder(GridConstants.SidebarColumnOrder order)
Set the order of the columns visible in the sidebar menu. Order defaults toGridConstants.SidebarColumnOrder.DEFAULT, i.e. "present column list in the order they were added".- Parameters:
order- new ordering mode- Since:
- 8.25
-
getSidebarColumnOrder
public GridConstants.SidebarColumnOrder getSidebarColumnOrder()
Get the current sidebar column order. Order defaults toGridConstants.SidebarColumnOrder.DEFAULT, i.e. "present column list in the order they were added".- Returns:
- a
GridConstants.SidebarColumnOrdervalue
-
recalculateColumnWidths
public void recalculateColumnWidths()
Requests that the column widths should be recalculated.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.
- Since:
- 8.1.1
-
setDetailsGenerator
public void setDetailsGenerator(DetailsGenerator<T> generator)
Sets the details component generator.- Parameters:
generator- the generator for details components
-
setDetailsVisible
public void setDetailsVisible(T item, boolean visible)
Sets the visibility of details component for given item.- Parameters:
item- the item to show details forvisible-trueif details component should be visible;falseif it should be hidden
-
isDetailsVisible
public boolean isDetailsVisible(T item)
Returns the visibility of details component for given item.- Parameters:
item- the item to show details for- Returns:
trueif details component should be visible;falseif it should be hidden
-
getColumns
public List<Grid.Column<T,?>> getColumns()
Gets an unmodifiable collection of all columns currently in thisGrid.- Returns:
- unmodifiable collection of columns
-
getColumn
public Grid.Column<T,?> getColumn(String columnId)
Gets aGrid.Columnof 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.- Parameters:
columnId- the identifier of the column to get- Returns:
- the column corresponding to the given column identifier, or
nullif there is no such column - See Also:
Grid.Column.setId(String)
-
iterator
public Iterator<Component> iterator()
Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.The iterator is typically unmodifiable, and calls to
Iterator.remove()throw an exception.Note that the order of the returned components it not specified.
- Specified by:
iteratorin interfaceHasComponents- Specified by:
iteratorin interfaceIterable<T>- Returns:
- the component iterator.
-
setFrozenColumnCount
public void setFrozenColumnCount(int numberOfColumns)
Sets the number of frozen columns in this grid. Setting the count to 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. Setting the count to -1 will also disable the selection column.NOTE: this count includes
hidden columnsin the count.The default value is 0.
- Parameters:
numberOfColumns- the number of columns that should be frozen- Throws:
IllegalArgumentException- if the column count is less than -1 or greater than the number of visible columns
-
getFrozenColumnCount
public int getFrozenColumnCount()
Gets the number of frozen columns in this grid. 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. -1 means that not even the selection column is frozen.NOTE: this count includes
hidden columnsin the count.- Returns:
- the number of frozen columns
- See Also:
setFrozenColumnCount(int)
-
setHeightByRows
public void setHeightByRows(double rows)
Sets the number of rows that should be visible in Grid's body. This method will set the height mode to beHeightMode.ROW.- Parameters:
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.- Throws:
IllegalArgumentException- ifrowsis zero or lessIllegalArgumentException- ifrowsisinfiniteIllegalArgumentException- ifrowsisNaN
-
getHeightByRows
public double getHeightByRows()
Gets the amount of rows in Grid's body that are shown, whilegetHeightMode()isHeightMode.ROW.- Returns:
- the amount of rows that are being shown in Grid's body
- See Also:
setHeightByRows(double)
-
setHeight
public void setHeight(float height, Sizeable.Unit unit)Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).Note: This method will set the height mode to be
HeightMode.CSS.- Specified by:
setHeightin interfaceSizeable- Overrides:
setHeightin classAbstractComponent- Parameters:
height- the height of the object.unit- the unit used for the width.- See Also:
setHeightMode(HeightMode)
-
setHeightMode
public void setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.If
HeightMode.CSSis given, Grid will respect the values given via asetHeight-method, and behave as a traditional Component.If
HeightMode.ROWis given, Grid will make sure that the body will display as many rows asgetHeightByRows()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.- Parameters:
heightMode- the mode in to which Grid should be set
-
getHeightMode
public HeightMode getHeightMode()
Returns the currentHeightModethe Grid is in.Defaults to
HeightMode.CSS.- Returns:
- the current HeightMode
-
setRowHeight
public void setRowHeight(double rowHeight)
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.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.
- Parameters:
rowHeight- The height of a row in pixels or -1 for automatic calculation- See Also:
setBodyRowHeight(double),setHeaderRowHeight(double),setFooterRowHeight(double)
-
setBodyRowHeight
public void setBodyRowHeight(double 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.- Parameters:
rowHeight- The height of a row in pixels or -1 for automatic calculation- Since:
- 8.2
-
setHeaderRowHeight
public void setHeaderRowHeight(double 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.- Parameters:
rowHeight- The height of a row in pixels or -1 for automatic calculation- Since:
- 8.2
-
setFooterRowHeight
public void setFooterRowHeight(double 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.- Parameters:
rowHeight- The height of a row in pixels or -1 for automatic calculation- Since:
- 8.2
-
getRowHeight
@Deprecated public double getRowHeight()
Deprecated.replaced by three separate row height controlsReturns the current body row height.-1 if row height is in automatic calculation mode.- Returns:
- body row height
- See Also:
getBodyRowHeight(),getHeaderRowHeight(),getFooterRowHeight()
-
getBodyRowHeight
public double getBodyRowHeight()
Returns the current body row height. -1 if row height is in automatic calculation mode.- Returns:
- body row height
- Since:
- 8.2
-
getHeaderRowHeight
public double getHeaderRowHeight()
Returns the current header row height. -1 if row height is in automatic calculation mode.- Returns:
- header row height
- Since:
- 8.2
-
getFooterRowHeight
public double getFooterRowHeight()
Returns the current footer row height. -1 if row height is in automatic calculation mode.- Returns:
- footer row height
- Since:
- 8.2
-
setStyleGenerator
public void setStyleGenerator(StyleGenerator<T> styleGenerator)
Sets the style generator that is used for generating class names for rows in this grid. Returning null from the generator results in no custom style name being set. Note: The style generator is applied only to the body cells, not to the Editor.- Parameters:
styleGenerator- the row style generator to set, not null- Throws:
NullPointerException- ifstyleGeneratorisnull- See Also:
StyleGenerator
-
getStyleGenerator
public StyleGenerator<T> getStyleGenerator()
Gets the style generator that is used for generating class names for rows.- Returns:
- the row style generator
- See Also:
StyleGenerator
-
setDescriptionGenerator
public void setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions for rows. This method uses theContentMode.PREFORMATTEDcontent mode.- Parameters:
descriptionGenerator- the row description generator to set, ornullto remove a previously set generator- See Also:
setDescriptionGenerator(DescriptionGenerator, ContentMode)
-
setDescriptionGenerator
public void setDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator, ContentMode contentMode)
Sets the description generator that is used for generating descriptions for rows. This method uses the given content mode.- Parameters:
descriptionGenerator- the row description generator to set, ornullto remove a previously set generatorcontentMode- the content mode for row tooltips- Since:
- 8.2
- See Also:
setDescriptionGenerator(DescriptionGenerator)
-
getDescriptionGenerator
public DescriptionGenerator<T> getDescriptionGenerator()
Gets the description generator that is used for generating descriptions for rows.- Returns:
- the row description generator, or
nullif no generator is set
-
getHeaderRow
public HeaderRow getHeaderRow(int index)
Returns the header row at the given index.- Parameters:
index- the index of the row, where the topmost row has index zero- Returns:
- the header row at the index
- Throws:
IndexOutOfBoundsException- ifrowIndex < 0 || rowIndex >= getHeaderRowCount()
-
getHeaderRowCount
public int getHeaderRowCount()
Gets the number of rows in the header section.- Returns:
- the number of header rows
-
addHeaderRowAt
public HeaderRow addHeaderRowAt(int index)
Inserts a new row at the given position to the header section. Shifts the row currently at that position and any subsequent rows down (adds one to their indices). Inserting atgetHeaderRowCount()appends the row at the bottom of the header.- Parameters:
index- the index at which to insert the row, where the topmost row has index zero- Returns:
- the inserted header row
- Throws:
IndexOutOfBoundsException- ifrowIndex < 0 || rowIndex > getHeaderRowCount()- See Also:
appendHeaderRow(),prependHeaderRow(),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
appendHeaderRow
public HeaderRow appendHeaderRow()
Adds a new row at the bottom of the header section.- Returns:
- the appended header row
- See Also:
prependHeaderRow(),addHeaderRowAt(int),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
prependHeaderRow
public HeaderRow prependHeaderRow()
Adds a new row at the top of the header section.- Returns:
- the prepended header row
- See Also:
appendHeaderRow(),addHeaderRowAt(int),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
removeHeaderRow
public void removeHeaderRow(HeaderRow row)
Removes the given row from the header section. Removing a default row sets the Grid to have no default row.- Parameters:
row- the header row to be removed, not null- Throws:
IllegalArgumentException- if the header does not contain the row- See Also:
removeHeaderRow(int),addHeaderRowAt(int),appendHeaderRow(),prependHeaderRow()
-
removeHeaderRow
public void removeHeaderRow(int index)
Removes the row at the given position from the header section.- Parameters:
index- the index of the row to remove, where the topmost row has index zero- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= getHeaderRowCount()- See Also:
removeHeaderRow(HeaderRow),addHeaderRowAt(int),appendHeaderRow(),prependHeaderRow()
-
setHeaderVisible
public void setHeaderVisible(boolean headerVisible)
Sets the visibility of the Header in this Grid.- Parameters:
headerVisible-trueif visible;falseif not- Since:
- 8.1.1
-
isHeaderVisible
public boolean isHeaderVisible()
Gets the visibility of the Header in this Grid.- Returns:
trueif visible;falseif not- Since:
- 8.1.1
-
getDefaultHeaderRow
public HeaderRow getDefaultHeaderRow()
Returns the current default row of the header.- Returns:
- the default row or null if no default row set
- See Also:
setDefaultHeaderRow(HeaderRow)
-
setDefaultHeaderRow
public void setDefaultHeaderRow(HeaderRow row)
Sets the default row of the header. The default row is a special header row that displays column captions and sort indicators. By default Grid has a single row which is also the default row. When a header row is set as the default row, any existing cell content is replaced by the column captions.- Parameters:
row- the new default row, or null for no default row- Throws:
IllegalArgumentException- if the header does not contain the row
-
getHeader
protected Header getHeader()
Returns the header section of this grid. The default header contains a single row, set as the default row.- Returns:
- the header section
-
getFooterRow
public FooterRow getFooterRow(int index)
Returns the footer row at the given index.- Parameters:
index- the index of the row, where the topmost row has index zero- Returns:
- the footer row at the index
- Throws:
IndexOutOfBoundsException- ifrowIndex < 0 || rowIndex >= getFooterRowCount()
-
getFooterRowCount
public int getFooterRowCount()
Gets the number of rows in the footer section.- Returns:
- the number of footer rows
-
addFooterRowAt
public FooterRow addFooterRowAt(int index)
Inserts a new row at the given position to the footer section. Shifts the row currently at that position and any subsequent rows down (adds one to their indices). Inserting atgetFooterRowCount()appends the row at the bottom of the footer.- Parameters:
index- the index at which to insert the row, where the topmost row has index zero- Returns:
- the inserted footer row
- Throws:
IndexOutOfBoundsException- ifrowIndex < 0 || rowIndex > getFooterRowCount()- See Also:
appendFooterRow(),prependFooterRow(),removeFooterRow(FooterRow),removeFooterRow(int)
-
appendFooterRow
public FooterRow appendFooterRow()
Adds a new row at the bottom of the footer section.- Returns:
- the appended footer row
- See Also:
prependFooterRow(),addFooterRowAt(int),removeFooterRow(FooterRow),removeFooterRow(int)
-
prependFooterRow
public FooterRow prependFooterRow()
Adds a new row at the top of the footer section.- Returns:
- the prepended footer row
- See Also:
appendFooterRow(),addFooterRowAt(int),removeFooterRow(FooterRow),removeFooterRow(int)
-
removeFooterRow
public void removeFooterRow(FooterRow row)
Removes the given row from the footer section. Removing a default row sets the Grid to have no default row.- Parameters:
row- the footer row to be removed, not null- Throws:
IllegalArgumentException- if the footer does not contain the row- See Also:
removeFooterRow(int),addFooterRowAt(int),appendFooterRow(),prependFooterRow()
-
removeFooterRow
public void removeFooterRow(int index)
Removes the row at the given position from the footer section.- Parameters:
index- the index of the row to remove, where the topmost row has index zero- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= getFooterRowCount()- See Also:
removeFooterRow(FooterRow),addFooterRowAt(int),appendFooterRow(),prependFooterRow()
-
setFooterVisible
public void setFooterVisible(boolean footerVisible)
Sets the visibility of the Footer in this Grid.- Parameters:
footerVisible-trueif visible;falseif not- Since:
- 8.1.1
-
isFooterVisible
public boolean isFooterVisible()
Gets the visibility of the Footer in this Grid.- Returns:
trueif visible;falseif not- Since:
- 8.1.1
-
getFooter
protected Footer getFooter()
Returns the footer section of this grid.- Returns:
- the footer section
-
addColumnReorderListener
public Registration addColumnReorderListener(ColumnReorderListener listener)
Registers a new column reorder listener.- Parameters:
listener- the listener to register, not null- Returns:
- a registration for the listener
-
addColumnResizeListener
public Registration addColumnResizeListener(ColumnResizeListener listener)
Registers a new column resize listener.- Parameters:
listener- the listener to register, not null- Returns:
- a registration for the listener
-
addItemClickListener
public Registration addItemClickListener(ItemClickListener<? super T> listener)
Adds an item click listener. The listener is called when an item of thisGridis clicked.- Parameters:
listener- the item click listener, not null- Returns:
- a registration for the listener
- See Also:
addContextClickListener(com.vaadin.event.ContextClickEvent.ContextClickListener)
-
addContextClickListener
public Registration addContextClickListener(ContextClickEvent.ContextClickListener listener)
Adds a context click listener that gets notified when a context click happens.- Specified by:
addContextClickListenerin interfaceContextClickEvent.ContextClickNotifier- Overrides:
addContextClickListenerin classAbstractComponent- Parameters:
listener- the context click listener to add, not null actual event provided to the listener isGrid.GridContextClickEvent- Returns:
- a registration object for removing the listener
- Since:
- 8.1
- See Also:
addItemClickListener(com.vaadin.ui.components.grid.ItemClickListener<? super T>),Registration
-
addColumnVisibilityChangeListener
public Registration addColumnVisibilityChangeListener(ColumnVisibilityChangeListener listener)
Registers a new column visibility change listener.- Parameters:
listener- the listener to register, not null- Returns:
- a registration for the listener
-
isColumnReorderingAllowed
public boolean isColumnReorderingAllowed()
Returns whether column reordering is allowed. Default value isfalse.- Returns:
- true if reordering is allowed
-
setColumnReorderingAllowed
public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether or not column reordering is allowed. Default value isfalse.- Parameters:
columnReorderingAllowed- specifies whether column reordering is allowed
-
setColumns
public void setColumns(String... columnIds)
Sets the columns and their order based on their column ids. Columns currently in this grid that are not present in the list of column ids are removed. This includes any column that has no id. Similarly, any new column in columns will be added to this grid. New columns can only be added for aGridcreated usingGrid(Class)orwithPropertySet(PropertySet).- Parameters:
columnIds- the column ids to set- See Also:
Grid.Column.setId(String)
-
setColumns
public void setColumns(Collection<String> columnIds)
Sets the columns and their order based on their column ids provided that collection supports preserving of the order. Columns currently in this grid that are not present in the collection of column ids are removed. This includes any column that has no id. Similarly, any new column in columns will be added to this grid. New columns can only be added for aGridcreated usingGrid(Class)orwithPropertySet(PropertySet).- Parameters:
columnIds- the column ids to set- See Also:
Grid.Column.setId(String),setColumns(String...)
-
setColumnOrder
public void setColumnOrder(Grid.Column<T,?>... columns)
Sets a new column order for the grid. All columns which are not ordered here will remain in the order they were before as the last columns of grid.- Parameters:
columns- the columns in the order they should be
-
setColumnOrder
public void setColumnOrder(String... columnIds)
Sets a new column order for the grid based on their column ids. All columns which are not ordered here will remain in the order they were before as the last columns of grid.- Parameters:
columnIds- the column ids in the order they should be- See Also:
Grid.Column.setId(String)
-
getSelectionModel
public GridSelectionModel<T> getSelectionModel()
Returns the selection model for this grid.- Returns:
- the selection model, not null
-
asSingleSelect
public GridSingleSelect<T> asSingleSelect()
Use this grid as a single select inBinder.Throws
IllegalStateExceptionif the grid is not using aSingleSelectionModel.- Returns:
- the single select wrapper that can be used in binder
- Throws:
IllegalStateException- if not using a single selection model
-
getEditor
public Editor<T> getEditor()
Returns theEditorfor this grid.- Returns:
- the editor, not null
-
asMultiSelect
public GridMultiSelect<T> asMultiSelect()
User this grid as a multiselect inBinder.Throws
IllegalStateExceptionif the grid is not using aMultiSelectionModel.- Returns:
- the multiselect wrapper that can be used in binder
- Throws:
IllegalStateException- if not using a multiselection model
-
setSelectionModel
protected void setSelectionModel(GridSelectionModel<T> model)
Sets the selection model for the grid.This method is for setting a custom selection model, and is
protectedbecausesetSelectionMode(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.
- Parameters:
model- the selection model to use, notnull- See Also:
setSelectionMode(SelectionMode)
-
setSelectionMode
public GridSelectionModel<T> setSelectionMode(Grid.SelectionMode selectionMode)
Sets the grid's selection mode.
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.- Parameters:
selectionMode- the selection mode to switch to, notnull- Returns:
- the used selection model
- See Also:
Grid.SelectionMode,GridSelectionModel,setSelectionModel(GridSelectionModel)
-
getSelectedItems
public Set<T> getSelectedItems()
This method is a shorthand that delegates to the currently set selection model.- Returns:
- the items in the current selection, not null
- See Also:
getSelectionModel(),GridSelectionModel
-
select
public void select(T item)
This method is a shorthand that delegates to the currently set selection model.- Parameters:
item- the item to select, not null- See Also:
getSelectionModel(),GridSelectionModel
-
deselect
public void deselect(T item)
This method is a shorthand that delegates to the currently set selection model.- Parameters:
item- the item to deselect, not null- See Also:
getSelectionModel(),GridSelectionModel
-
deselectAll
public void deselectAll()
This method is a shorthand that delegates to the currently set selection model.- See Also:
getSelectionModel(),GridSelectionModel
-
addSelectionListener
public Registration addSelectionListener(SelectionListener<T> listener) throws UnsupportedOperationException
Adds a selection listener to the current selection model.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, usegetSelectionModel()and eitherSingleSelectionModel.addSingleSelectionListener(SingleSelectionListener)orMultiSelectionModel.addMultiSelectionListener(MultiSelectionListener)depending on the used selection mode.- Parameters:
listener- the listener to add- Returns:
- a registration handle to remove the listener
- Throws:
UnsupportedOperationException- if selection has been disabled withGrid.SelectionMode.NONE
-
sort
public void sort(Grid.Column<T,?> column)
Sort this Grid in ascending order by a specified column.- Parameters:
column- a column to sort against
-
sort
public void sort(Grid.Column<T,?> column, SortDirection direction)
Sort this Grid in user-specified direction by a column.- Parameters:
column- a column to sort againstdirection- a sort order value (ascending/descending)
-
sort
public void sort(String columnId)
Sort this Grid in ascending order by a specified column defined by id.- Parameters:
columnId- the id of the column to sort against- See Also:
Grid.Column.setId(String)
-
sort
public void sort(String columnId, SortDirection direction)
Sort this Grid in a user-specified direction by a column defined by id.- Parameters:
columnId- the id of the column to sort againstdirection- a sort order value (ascending/descending)- See Also:
Grid.Column.setId(String)
-
clearSortOrder
public void clearSortOrder()
Clear the current sort order, and re-sort the grid.
-
setSortOrder
public void setSortOrder(List<GridSortOrder<T>> order)
Sets the sort order to use.- Parameters:
order- a sort order list.- Throws:
IllegalArgumentException- if order is null
-
setSortOrder
public void setSortOrder(GridSortOrderBuilder<T> builder)
Sets the sort order to use, given aGridSortOrderBuilder. Shorthand forsetSortOrder(builder.build()).- Parameters:
builder- the sort builder to retrieve the sort order from- Throws:
NullPointerException- if builder is null- See Also:
GridSortOrderBuilder
-
addSortListener
public Registration addSortListener(SortEvent.SortListener<GridSortOrder<T>> listener)
Adds a sort order change listener that gets notified when the sort order changes.- Specified by:
addSortListenerin interfaceSortEvent.SortNotifier<T>- Parameters:
listener- the sort order change listener to add- Returns:
- a registration object for removing the listener
-
getSortOrder
public List<GridSortOrder<T>> getSortOrder()
Get the current sort order list.- Returns:
- a sort order list
-
scrollTo
public void scrollTo(int row) throws IllegalArgumentExceptionScrolls to a certain item, usingScrollDestination.ANY.If the item has an open details row, its size will also be taken into account.
- Parameters:
row- zero based index of the item to scroll to in the current view.- Throws:
IllegalArgumentException- if the provided row is outside the item range
-
scrollTo
public void scrollTo(int row, ScrollDestination destination)Scrolls to a certain item, using user-specified scroll destination.If the item has an open details row, its size will also be taken into account.
- Parameters:
row- zero based index of the item to scroll to in the current view.destination- value specifying desired position of scrolled-to row, notnull- Throws:
IllegalArgumentException- if the provided row is outside the item range
-
scrollToStart
public void scrollToStart()
Scrolls to the beginning of the first data row.
-
scrollToEnd
public void scrollToEnd()
Scrolls to the end of the last data row.
-
scrollToColumn
public void scrollToColumn(String columnId)
Scrolls to the given column, usingScrollDestination.ANY.- Parameters:
columnId- the id of the column, notnull- Throws:
IllegalArgumentException- if there is no column with the given id- Since:
- 8.18
-
scrollToColumn
public void scrollToColumn(String columnId, ScrollDestination destination)
Scrolls to the given column, using the given scroll destination.- Parameters:
columnId- the id of the column, notnulldestination- value specifying desired position of scrolled-to column, notnull- Throws:
IllegalArgumentException- if there is no column with the given id- Since:
- 8.18
-
scrollToColumn
public void scrollToColumn(Grid.Column<T,?> column)
Scrolls to the given column, usingScrollDestination.ANY.- Parameters:
column- the column to scroll to, notnull- Since:
- 8.18
-
scrollToColumn
public void scrollToColumn(Grid.Column<T,?> column, ScrollDestination destination)
Scrolls to the given column, using the given scroll destination.- Parameters:
column- the column to scroll to, notnulldestination- value specifying desired position of scrolled-to column, notnull- Since:
- 8.18
-
getState
protected GridState getState()
Description copied from class:AbstractComponentReturns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().- Overrides:
getStatein classAbstractListing<T>- Returns:
- updated component shared state
-
getState
protected GridState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractListing<T>- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
setColumnResizeMode
public void setColumnResizeMode(ColumnResizeMode mode)
Sets the column resize mode to use. The default mode isColumnResizeMode.ANIMATED.- Parameters:
mode- a ColumnResizeMode value- Since:
- 7.7.5
-
getColumnResizeMode
public ColumnResizeMode getColumnResizeMode()
Returns the current column resize mode. The default mode isColumnResizeMode.ANIMATED.- Returns:
- a ColumnResizeMode value
- Since:
- 7.7.5
-
createEditor
protected Editor<T> createEditor()
Creates a new Editor instance. Can be overridden to create a custom Editor. If the Editor is aGrid.AbstractGridExtension, it will be automatically added toDataCommunicator.- Returns:
- editor
-
readItems
protected void readItems(org.jsoup.nodes.Element design, DesignContext context)Description copied from class:AbstractListingReads the data source items from thedesign.- Specified by:
readItemsin classAbstractListing<T>- Parameters:
design- The element to obtain the state fromcontext- The DesignContext instance used for parsing the design
-
getDataProvider
public DataProvider<T,?> getDataProvider()
Description copied from interface:HasItemsReturns the source of data items used by this listing.- Specified by:
getDataProviderin interfaceHasItems<T>- Returns:
- the data provider, not null
-
setDataProvider
public void setDataProvider(DataProvider<T,?> dataProvider)
Description copied from interface:HasDataProviderSets the data provider for this listing. The data provider is queried for displayed items as needed.- Specified by:
setDataProviderin interfaceHasDataProvider<T>- Parameters:
dataProvider- the data provider, not null
-
setDataProvider
public void setDataProvider(Grid.FetchItemsCallback<T> fetchItems, SerializableSupplier<Integer> sizeCallback)
Sets a CallbackDataProvider using the given fetch items callback and a size callback.This method is a shorthand for making a
CallbackDataProviderthat handles a partialQueryobject.- Parameters:
fetchItems- a callback for fetching itemssizeCallback- a callback for getting the count of items- See Also:
CallbackDataProvider,setDataProvider(DataProvider)
-
doReadDesign
protected void doReadDesign(org.jsoup.nodes.Element design, DesignContext context)Description copied from class:AbstractListingReads the listing specific state from the given design.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 callsuper.readDesign(...).- Overrides:
doReadDesignin classAbstractListing<T>- Parameters:
design- The element to obtain the state fromcontext- The DesignContext instance used for parsing the design- See Also:
AbstractListing.doWriteDesign(Element, DesignContext)
-
setBeanType
protected void setBeanType(String beanTypeClassName)
Sets the bean type to use for property mapping.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.
- Parameters:
beanTypeClassName- the fully qualified class name of the bean type- Since:
- 8.0.3
-
setBeanType
protected void setBeanType(Class<T> beanType)
Sets the bean type to use for property mapping.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.
- Parameters:
beanType- the bean type class- Since:
- 8.0.3
-
doWriteDesign
protected void doWriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from class:AbstractListingWrites listing specific state into the given design.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 callsuper.writeDesign(...).- Overrides:
doWriteDesignin classAbstractListing<T>- Parameters:
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 design- See Also:
AbstractListing.doReadDesign(Element, DesignContext)
-
deserializeDeclarativeRepresentation
protected T deserializeDeclarativeRepresentation(String item)
Description copied from class:AbstractListingDeserializes a string to a data item.Default implementation is able to handle only
Stringas an item type. There will be aClassCastExceptionifTis not aString.- Overrides:
deserializeDeclarativeRepresentationin classAbstractListing<T>- Parameters:
item- string to deserialize- Returns:
- deserialized item
- See Also:
AbstractListing.serializeDeclarativeRepresentation(Object)
-
isAccessibleNavigation
public boolean isAccessibleNavigation()
Check whether accessible navigation mode is on.- Returns:
- boolean value.
- Since:
- 8.28
-
setAccessibleNavigation
public void setAccessibleNavigation(boolean accessibleNavigation)
Sets whether accessible navigation is enabled for the grid.- Parameters:
accessibleNavigation-trueto enable accessible navigation,falseto disable it.- Since:
- 8.28
-
isReadOnly
public boolean isReadOnly()
Description copied from class:AbstractComponentReturns the read-only status from the state of thisAbstractComponent. This method should be made public inComponentsthat implementHasValue.- Overrides:
isReadOnlyin classAbstractComponent- Returns:
trueif state has read-only on;falseif not- See Also:
AbstractComponent.setReadOnly(boolean)
-
setReadOnly
public void setReadOnly(boolean readOnly)
Description copied from class:AbstractComponentSets the read-only status in the state of thisAbstractComponent. This method should be made public inComponentsthat implementHasValue.- Overrides:
setReadOnlyin classAbstractComponent- Parameters:
readOnly- a boolean value specifying whether the component is put read-only mode or not
-
readData
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 givenDeclarativeValueProviders. Each member in the list of value providers corresponds to a column in the grid.- Parameters:
body- the element to read data fromproviders- list ofDeclarativeValueProviders to store the data of each column to- Since:
- 8.1
-
writeData
protected void writeData(org.jsoup.nodes.Element body, DesignContext designContext)Writes the data contained in this grid. Used when serializing a grid to its declarative representation, ifDesignContext.shouldWriteData(Component)returnstruefor the grid that is being written.- Parameters:
body- the body element to write the declarative representation of data todesignContext- the design context- Since:
- 8.1, 8.1
-
setColumnId
protected void setColumnId(String id, Grid.Column<T,?> column)
Sets a user-defined identifier for given column.- Parameters:
column- the columnid- the user-defined identifier- See Also:
Grid.Column.setId(String)
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponentReturns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributesin classAbstractComponent- Returns:
- the collection of attributes that are not handled by the basic implementation
-
getColumnByInternalId
protected Grid.Column<T,?> getColumnByInternalId(String columnId)
Returns a column identified by its internal id. This id should not be confused with the user-defined identifier.- Parameters:
columnId- the internal id of column- Returns:
- column identified by internal id
-
getInternalIdForColumn
protected String getInternalIdForColumn(Grid.Column<T,?> column)
Returns the internal id for given column. This id should not be confused with the user-defined identifier.- Parameters:
column- the column- Returns:
- internal id of given column
-
createSortingComparator
protected SerializableComparator<T> createSortingComparator()
Creates a comparator for grid to sort rows.- Returns:
- the comparator based on column sorting information.
-
internalSetDataProvider
protected void internalSetDataProvider(DataProvider<T,?> dataProvider)
- Overrides:
internalSetDataProviderin classAbstractListing<T>
-
-