Class Grid<T>
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Composite
-
- com.google.gwt.user.client.ui.ResizeComposite
-
- com.vaadin.v7.client.widgets.Grid<T>
-
- Type Parameters:
T- The row type of the grid. The row type is the POJO type from where the data is retrieved into the column cells.
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.Focusable,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.HasWidgets,com.google.gwt.user.client.ui.IsRenderable,com.google.gwt.user.client.ui.IsWidget,com.google.gwt.user.client.ui.RequiresResize,DeferredWorker,Focusable,SubPartAware,HasSelectionHandlers<T>,Iterable<com.google.gwt.user.client.ui.Widget>
public class Grid<T> extends com.google.gwt.user.client.ui.ResizeComposite implements HasSelectionHandlers<T>, SubPartAware, DeferredWorker, Focusable, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.HasEnabled
A data grid view that supports columns and lazy loading of data rows from a data source.Columns
Each column in Grid is represented by a
Grid.Column. EachGridColumnhas a custom implementation forGrid.Column.getValue(Object)that gets the row object as an argument, and returns the value for that particular column, extracted from the row object.Each column also has a Renderer. Its function is to take the value that is given by the
GridColumnand display it to the user. A simple column might have aTextRendererthat simply takes in aStringand displays it as the cell's content. A more complex renderer might beProgressBarRendererthat takes in a floating point number, and displays a progress bar instead, based on the given number.See:
addColumn(Column),addColumn(Column, int)andaddColumns(Column...). AlsoGrid.Column.setRenderer(Renderer).Data Sources
Grid gets its data from a
DataSource, providing row objects to Grid from a user-defined endpoint. It can be either a local in-memory data source (e.g.ListDataSource) or even a remote one, retrieving data from e.g. a REST API (seeAbstractRemoteDataSource).- Since:
- 7.4
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrid.AbstractGridKeyEvent<HANDLER extends AbstractGridKeyEventHandler>static classGrid.AbstractGridMouseEvent<HANDLER extends AbstractGridMouseEventHandler>protected classGrid.BodyUpdaterstatic classGrid.Column<C,T>Base class for grid columns internally used by the Grid.static classGrid.Editor<T>An editor UI for Grid rows.static classGrid.EditorDomEvent<T>A wrapper for native DOM events related to theGrid editor.protected static classGrid.FooterRepresents the footer section of a Grid.static classGrid.FooterCellA single cell in a grid Footer row.static classGrid.FooterRowA single row in a grid Footer section.static classGrid.GridEvent<T>A wrapper for native DOM events originating from Grid.protected static classGrid.HeaderRepresents the header section of a Grid.static classGrid.HeaderCellA single cell in a grid header row.static classGrid.HeaderRowA single row in a grid header section.classGrid.SelectionColumnstatic classGrid.SelectionModeEnumeration for easy setting of selection mode.static classGrid.StaticSection<ROWTYPE extends Grid.StaticSection.StaticRow<?>>Abstract base class for Grid header and footer sections.protected classGrid.StaticSectionUpdater
-
Field Summary
Fields Modifier and Type Field Description protected com.vaadin.v7.client.widgets.Grid.CellFocusHandlercellFocusHandler
-
Constructor Summary
Constructors Constructor Description Grid()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(com.google.gwt.user.client.ui.Widget w)Deprecated.com.google.gwt.event.shared.HandlerRegistrationaddBodyClickHandler(BodyClickHandler handler)Register a BodyClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddBodyDoubleClickHandler(BodyDoubleClickHandler handler)Register a BodyDoubleClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddBodyKeyDownHandler(BodyKeyDownHandler handler)Register a BodyKeyDownHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddBodyKeyPressHandler(BodyKeyPressHandler handler)Register a BodyKeyPressHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddBodyKeyUpHandler(BodyKeyUpHandler handler)Register a BodyKeyUpHandler to this Grid.voidaddBrowserEventHandler(int index, GridEventHandler<T> handler)Adds a low-level DOM event handler to this Grid.<C extends Grid.Column<?,T>>
CaddColumn(C column)Adds a column as the last column in the grid.<C extends Grid.Column<?,T>>
CaddColumn(C column, int index)Inserts a column into a specific position in the grid.com.google.gwt.event.shared.HandlerRegistrationaddColumnReorderHandler(ColumnReorderHandler<T> handler)Register a column reorder handler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddColumnResizeHandler(ColumnResizeHandler<T> handler)Register a column resize handler to this Grid.voidaddColumns(Grid.Column<?,T>... columns)Adds columns as the last columns in the grid.com.google.gwt.event.shared.HandlerRegistrationaddColumnVisibilityChangeHandler(ColumnVisibilityChangeHandler<T> handler)Register a column visibility change handler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddDataAvailableHandler(DataAvailableHandler handler)Register a GWT event handler for a data available event.com.google.gwt.event.shared.HandlerRegistrationaddEnabledHandler(GridEnabledHandler handler)Register a enabled status change handler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddFooterClickHandler(FooterClickHandler handler)Register a FooterClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddFooterDoubleClickHandler(FooterDoubleClickHandler handler)Register a FooterDoubleClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddFooterKeyDownHandler(FooterKeyDownHandler handler)Register a FooterKeyDownHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddFooterKeyPressHandler(FooterKeyPressHandler handler)Register a FooterKeyPressHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddFooterKeyUpHandler(FooterKeyUpHandler handler)Register a FooterKeyUpHandler to this Grid.Grid.FooterRowaddFooterRowAt(int index)Inserts a new row at the given position to the footer section.com.google.gwt.event.shared.HandlerRegistrationaddHeaderClickHandler(HeaderClickHandler handler)Register a HeaderClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddHeaderDoubleClickHandler(HeaderDoubleClickHandler handler)Register a HeaderDoubleClickHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddHeaderKeyDownHandler(HeaderKeyDownHandler handler)Register a HeaderKeyDownHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddHeaderKeyPressHandler(HeaderKeyPressHandler handler)Register a HeaderKeyPressHandler to this Grid.com.google.gwt.event.shared.HandlerRegistrationaddHeaderKeyUpHandler(HeaderKeyUpHandler handler)Register a HeaderKeyUpHandler to this Grid.Grid.HeaderRowaddHeaderRowAt(int index)Inserts a new row at the given position to the header section.com.google.gwt.event.shared.HandlerRegistrationaddRowHeightChangedHandler(RowHeightChangedHandler handler)com.google.gwt.event.shared.HandlerRegistrationaddRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)com.google.gwt.event.shared.HandlerRegistrationaddScrollHandler(ScrollHandler handler)Adds a scroll handler to this grid.com.google.gwt.event.shared.HandlerRegistrationaddSelectAllHandler(SelectAllHandler<T> handler)Register a GWT event handler for a select all event.com.google.gwt.event.shared.HandlerRegistrationaddSelectionHandler(SelectionHandler<T> handler)Register a selection change handler.com.google.gwt.event.shared.HandlerRegistrationaddSortHandler(SortHandler<T> handler)Register a GWT event handler for a sorting event.com.google.gwt.event.shared.HandlerRegistrationaddSpacerVisibilityChangedHandler(SpacerVisibilityChangedHandler handler)Adds a spacer visibility changed handler to the underlying escalator.Grid.FooterRowappendFooterRow()Adds a new row at the bottom of the footer section.Grid.HeaderRowappendHeaderRow()Adds a new row at the bottom of the header section.voidcancelEditor()Cancels the currently active edit and hides the editor.voidclear()Deprecated.protected EscalatorUpdatercreateBodyUpdater()Creates the escalator updater used to update the body rows in this grid.protected EscalatorUpdatercreateFooterUpdater()Creates the escalator updater used to update the footer rows in this grid.protected EscalatorUpdatercreateHeaderUpdater()Creates the escalator updater used to update the header rows in this grid.booleandeselect(T row)Deselect a row using the current selection model.booleandeselectAll()Deselect all rows using the current selection model.protected voiddoAttachChildren()protected voiddoDetachChildren()voideditRow(int rowIndex)Opens the editor over the row with the given index.voidfocus()CellReference<T>getCellReference(com.google.gwt.dom.client.Element element)Returns a CellReference for the cell to which the given element belongs to.CellStyleGenerator<T>getCellStyleGenerator()Gets the style generator that is used for generating styles for cells.Grid.Column<?,T>getColumn(int index)Returns a column by its index in the grid.intgetColumnCount()Returns the amount of columns in the grid.ColumnResizeModegetColumnResizeMode()Returns the current column resize mode.List<Grid.Column<?,T>>getColumns()Returns a list columns in the grid, including hidden columns.DataSource<T>getDataSource()Gets the for this Grid.Grid.HeaderRowgetDefaultHeaderRow()Returns the current default row of the header section.DetailsGeneratorgetDetailsGenerator()Gets the current details generator for row details.Grid.Editor<T>getEditor()StringgetEditorCancelCaption()Gets the caption on the cancel button in the Grid editor.EditorHandler<T>getEditorHandler()Returns the handler responsible for binding data and editor widgets to the editor.StringgetEditorSaveCaption()Gets the current caption on the save button in the Grid editor.com.google.gwt.user.client.ui.WidgetgetEditorWidget(Grid.Column<?,T> column)Returns the editor widget associated with the given column.EscalatorgetEscalator()Gets theEscalatorused by this Grid instance.EventCellReference<T>getEventCell()Returns theEventCellReferencefor the latest event fired from this Grid.protected Grid.FootergetFooter()Returns the footer section of this grid.Grid.FooterRowgetFooterRow(int rowIndex)Gets the footer row at given index.intgetFooterRowCount()Gets the row count for the footer.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 Grid.HeadergetHeader()Returns the header section of this grid.Grid.HeaderRowgetHeaderRow(int rowIndex)Gets the header row at given index.intgetHeaderRowCount()Gets the row count for the header section.doublegetHeightByRows()Gets the amount of rows in Grid's body that are shown, whilegetHeightMode()isHeightMode.ROW.HeightModegetHeightMode()Returns the currentHeightModethe Grid is in.RowStyleGenerator<T>getRowStyleGenerator()Gets the style generator that is used for generating styles for rows.doublegetScrollHeight()Returns the height of the scrollable area in pixels.doublegetScrollLeft()Gets the horizontal scroll offset.doublegetScrollTop()Gets the vertical scroll offset.doublegetScrollWidth()Returns the width of the scrollable area in pixels.TgetSelectedRow()Gets last selected row from the current SelectionModel.Collection<T>getSelectedRows()Gets currently selected rows from the current selection model.SelectionModel<T>getSelectionModel()Gets a reference to the current selection model.com.google.gwt.user.client.ui.MenuBargetSidebarMenu()Gets the customizable menu bar that is by default used for toggling column hidability.List<SortOrder>getSortOrder()Get a copy of the current sort order array.com.google.gwt.user.client.ElementgetSubPartElement(String subPart)StringgetSubPartName(com.google.gwt.user.client.Element subElement)intgetTabIndex()List<Grid.Column<?,T>>getVisibleColumns()Returns a list of the currently visible columns in the grid.booleanisColumnReorderingAllowed()Returns whether columns can be reordered with drag and drop.booleanisDetailsVisible(int rowIndex)Check whether the details for a row is visible or not.booleanisEditorActive()Returns whether the editor is currently open on some row.booleanisEditorBuffered()Gets the buffered editor mode.booleanisEditorEnabled()Returns the enabled state of the editor.booleanisEnabled()booleanisFooterVisible()Returns the visibility of the footer section.booleanisHeaderVisible()Returns the visibility of the header section.booleanisSelected(T row)Test if a row is selected.booleanisSidebarOpen()Tests whether the sidebar menu is currently open.booleanisUserSelectionAllowed()Checks if selection by the user is allowed in the grid.booleanisWorkPending()Iterator<com.google.gwt.user.client.ui.Widget>iterator()Deprecated.protected voidonAttach()voidonBrowserEvent(com.google.gwt.user.client.Event event)protected voidonDetach()voidonResize()Grid.FooterRowprependFooterRow()Adds a new row at the top of the footer section.Grid.HeaderRowprependHeaderRow()Adds a new row at the top of the header section.voidrecalculateColumnWidths()Requests that the column widths should be recalculated.booleanremove(com.google.gwt.user.client.ui.Widget w)Deprecated.voidremoveColumn(Grid.Column<?,T> column)Removes a column from the grid.voidremoveFooterRow(int rowIndex)Removes the row at the given position from the footer section.voidremoveFooterRow(Grid.FooterRow row)Removes the given row from the footer section.voidremoveHeaderRow(int rowIndex)Removes the row at the given position from the header section.voidremoveHeaderRow(Grid.HeaderRow row)Removes the given row from the header section.voidresetSizesFromDom()Resets all cached pixel sizes and reads new values from the DOM.voidsaveEditor()Saves any unsaved changes in the editor to the data source.voidscrollToEnd()Scrolls to the end of the very last row.voidscrollToRow(int rowIndex)Scrolls to a certain row, usingScrollDestination.ANY.voidscrollToRow(int rowIndex, ScrollDestination destination)Scrolls to a certain row, using user-specified scroll destination.voidscrollToStart()Scrolls to the beginning of the very first row.booleanselect(T row)Select a row using the current selection model.voidsetAccessKey(char key)voidsetCellStyleGenerator(CellStyleGenerator<T> cellStyleGenerator)Sets the style generator that is used for generating styles for cells.voidsetColumnOrder(Grid.Column<?,T>... orderedColumns)Sets a new column order for the grid.voidsetColumnReorderingAllowed(boolean columnReorderingAllowed)Sets whether column reordering with drag and drop is allowed or not.voidsetColumnResizeMode(ColumnResizeMode mode)Sets the column resize mode to use.voidsetDataSource(DataSource<T> dataSource)Sets the data source used by this grid.voidsetDefaultHeaderRow(Grid.HeaderRow row)Sets the default row of the header.voidsetDetailsGenerator(DetailsGenerator detailsGenerator)Sets a new details generator for row details.voidsetDetailsHeight(int rowIndex, double height)Update details row height.voidsetDetailsVisible(int rowIndex, boolean visible)Shows or hides the details for a specific row.voidsetEditorBuffered(boolean editorBuffered)Sets the buffered editor mode.voidsetEditorCancelCaption(String cancelCaption)Sets the caption on the cancel button in the Grid editor.voidsetEditorEnabled(boolean enabled)Sets the enabled state of the editor.voidsetEditorHandler(EditorHandler<T> handler)Sets the handler responsible for binding data and editor widgets to the editor.voidsetEditorSaveCaption(String saveCaption)Sets the caption on the save button in the Grid editor.voidsetEnabled(boolean enabled)voidsetFocus(boolean focused)voidsetFooterVisible(boolean visible)Sets the visibility of the footer section.voidsetFrozenColumnCount(int numberOfColumns)Sets the number of frozen columns in this grid.voidsetHeaderVisible(boolean visible)Sets the visibility of the header section.voidsetHeight(String height)voidsetHeightByRows(double rows)Sets the number of rows that should be visible in Grid's body, whilegetHeightMode()isHeightMode.ROW.voidsetHeightMode(HeightMode heightMode)Defines the mode in which the Grid widget's height is calculated.voidsetRowStyleGenerator(RowStyleGenerator<T> rowStyleGenerator)Sets the style generator that is used for generating styles for rows.voidsetScrollLeft(double px)Sets the horizontal scroll offset.voidsetScrollTop(double px)Sets the vertical scroll offset.voidsetSelectionMode(Grid.SelectionMode mode)Sets current selection mode.voidsetSelectionModel(SelectionModel<T> selectionModel)Sets the current selection model.voidsetSidebarOpen(boolean sidebarOpen)Sets whether the sidebar menu is open.voidsetSortOrder(List<SortOrder> order)Sets the sort order to use.voidsetStylePrimaryName(String style)voidsetTabIndex(int index)voidsetWidth(String width)voidsort(Sort s)Sets the current sort order using the fluid Sort API.<C> voidsort(Grid.Column<C,T> column)Sorts the Grid data in ascending order along one column.<C> voidsort(Grid.Column<C,T> column, com.vaadin.shared.data.sort.SortDirection direction)Sorts the Grid data along one column.-
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, isAttached, render, render, resolvePotentialElement, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
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
-
setStylePrimaryName
public void setStylePrimaryName(String style)
- Overrides:
setStylePrimaryNamein classcom.google.gwt.user.client.ui.UIObject
-
createHeaderUpdater
protected EscalatorUpdater createHeaderUpdater()
Creates the escalator updater used to update the header rows in this grid. The updater is invoked when header rows or columns are added or removed, or the content of existing header cells is changed.- Returns:
- the new header updater instance
- See Also:
GridHeader,getHeader()
-
createBodyUpdater
protected EscalatorUpdater createBodyUpdater()
Creates the escalator updater used to update the body rows in this grid. The updater is invoked when body rows or columns are added or removed, the content of body cells is changed, or the body is scrolled to expose previously hidden content.- Returns:
- the new body updater instance
-
createFooterUpdater
protected EscalatorUpdater createFooterUpdater()
Creates the escalator updater used to update the footer rows in this grid. The updater is invoked when header rows or columns are added or removed, or the content of existing header cells is changed.- Returns:
- the new footer updater instance
- See Also:
GridFooter,getFooter()
-
addColumns
public void addColumns(Grid.Column<?,T>... columns)
Adds columns as the last columns in the grid.- Parameters:
columns- the columns to add
-
addColumn
public <C extends Grid.Column<?,T>> C addColumn(C column)
Adds a column as the last column in the grid.- Parameters:
column- the column to add- Returns:
- given column
-
addColumn
public <C extends Grid.Column<?,T>> C addColumn(C column, int index)
Inserts a column into a specific position in the grid.- Parameters:
index- the index where the column should be inserted intocolumn- the column to add- Returns:
- given column
- Throws:
IllegalStateException- if Grid's current selection model renders a selection column, andindexis 0.
-
removeColumn
public void removeColumn(Grid.Column<?,T> column)
Removes a column from the grid.- Parameters:
column- the column to remove
-
getColumnCount
public int getColumnCount()
Returns the amount of columns in the grid.NOTE: this includes the hidden columns in the count.
- Returns:
- The number of columns in the grid
-
getColumns
public List<Grid.Column<?,T>> getColumns()
Returns a list columns in the grid, including hidden columns.For currently visible columns, use
getVisibleColumns().- Returns:
- A unmodifiable list of the columns in the grid
-
getVisibleColumns
public List<Grid.Column<?,T>> getVisibleColumns()
Returns a list of the currently visible columns in the grid.No
hiddencolumns included.- Returns:
- A unmodifiable list of the currently visible columns in the grid
- Since:
- 7.5.0
-
getColumn
public Grid.Column<?,T> getColumn(int index) throws IllegalArgumentException
Returns a column by its index in the grid.NOTE: The indexing includes hidden columns.
- Parameters:
index- the index of the column- Returns:
- The column in the given index
- Throws:
IllegalArgumentException- if the column index does not exist in the grid
-
getHeader
protected Grid.Header getHeader()
Returns the header section of this grid. The default header contains a single row displaying the column captions.- Returns:
- the header
-
getHeaderRow
public Grid.HeaderRow getHeaderRow(int rowIndex)
Gets the header row at given index.- Parameters:
rowIndex- 0 based index for row. Counted from top to bottom- Returns:
- header row at given index
- Throws:
IllegalArgumentException- if no row exists at given index
-
addHeaderRowAt
public Grid.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).- Parameters:
index- the position at which to insert the row- Returns:
- the new row
- Throws:
IllegalArgumentException- if the index is less than 0 or greater than row count- See Also:
appendHeaderRow(),prependHeaderRow(),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
appendHeaderRow
public Grid.HeaderRow appendHeaderRow()
Adds a new row at the bottom of the header section.- Returns:
- the new row
- See Also:
prependHeaderRow(),addHeaderRowAt(int),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
getDefaultHeaderRow
public Grid.HeaderRow getDefaultHeaderRow()
Returns the current default row of the header section. The default row is a special header row providing a user interface for sorting columns. Setting a header caption for column updates cells in the default header.- Returns:
- the default row or null if no default row set
-
getHeaderRowCount
public int getHeaderRowCount()
Gets the row count for the header section.- Returns:
- row count
-
prependHeaderRow
public Grid.HeaderRow prependHeaderRow()
Adds a new row at the top of the header section.- Returns:
- the new row
- See Also:
appendHeaderRow(),addHeaderRowAt(int),removeHeaderRow(HeaderRow),removeHeaderRow(int)
-
removeHeaderRow
public void removeHeaderRow(Grid.HeaderRow row)
Removes the given row from the header section.- Parameters:
row- the row to be removed- Throws:
IllegalArgumentException- if the row does not exist in this section- See Also:
removeHeaderRow(int),addHeaderRowAt(int),appendHeaderRow(),prependHeaderRow()
-
removeHeaderRow
public void removeHeaderRow(int rowIndex)
Removes the row at the given position from the header section.- Parameters:
rowIndex- the index of the row- Throws:
IllegalArgumentException- if no row exists at given index- See Also:
removeHeaderRow(HeaderRow),addHeaderRowAt(int),appendHeaderRow(),prependHeaderRow()
-
setDefaultHeaderRow
public void setDefaultHeaderRow(Grid.HeaderRow row)
Sets the default row of the header. The default row is a special header row providing a user interface for sorting columns.Note: Setting the default header row will reset all cell contents to Column defaults.
- Parameters:
row- the new default row, or null for no default row- Throws:
IllegalArgumentException- header does not contain the row
-
setHeaderVisible
public void setHeaderVisible(boolean visible)
Sets the visibility of the header section.- Parameters:
visible- true to show header section, false to hide
-
isHeaderVisible
public boolean isHeaderVisible()
Returns the visibility of the header section.- Returns:
- true if visible, false otherwise.
-
getFooter
protected Grid.Footer getFooter()
Returns the footer section of this grid. The default footer is empty.- Returns:
- the footer
-
getFooterRow
public Grid.FooterRow getFooterRow(int rowIndex)
Gets the footer row at given index.- Parameters:
rowIndex- 0 based index for row. Counted from top to bottom- Returns:
- footer row at given index
- Throws:
IllegalArgumentException- if no row exists at given index
-
addFooterRowAt
public Grid.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).- Parameters:
index- the position at which to insert the row- Returns:
- the new row
- Throws:
IllegalArgumentException- if the index is less than 0 or greater than row count- See Also:
appendFooterRow(),prependFooterRow(),removeFooterRow(FooterRow),removeFooterRow(int)
-
appendFooterRow
public Grid.FooterRow appendFooterRow()
Adds a new row at the bottom of the footer section.- Returns:
- the new row
- See Also:
prependFooterRow(),addFooterRowAt(int),removeFooterRow(FooterRow),removeFooterRow(int)
-
getFooterRowCount
public int getFooterRowCount()
Gets the row count for the footer.- Returns:
- row count
-
prependFooterRow
public Grid.FooterRow prependFooterRow()
Adds a new row at the top of the footer section.- Returns:
- the new row
- See Also:
appendFooterRow(),addFooterRowAt(int),removeFooterRow(FooterRow),removeFooterRow(int)
-
removeFooterRow
public void removeFooterRow(Grid.FooterRow row)
Removes the given row from the footer section.- Parameters:
row- the row to be removed- Throws:
IllegalArgumentException- if the row does not exist in this section- See Also:
removeFooterRow(int),addFooterRowAt(int),appendFooterRow(),prependFooterRow()
-
removeFooterRow
public void removeFooterRow(int rowIndex)
Removes the row at the given position from the footer section.- Parameters:
rowIndex- the position of the row- Throws:
IllegalArgumentException- if no row exists at given index- See Also:
removeFooterRow(FooterRow),addFooterRowAt(int),appendFooterRow(),prependFooterRow()
-
setFooterVisible
public void setFooterVisible(boolean visible)
Sets the visibility of the footer section.- Parameters:
visible- true to show footer section, false to hide
-
isFooterVisible
public boolean isFooterVisible()
Returns the visibility of the footer section.- Returns:
- true if visible, false otherwise.
-
getEditor
public Grid.Editor<T> getEditor()
-
getEscalator
public Escalator getEscalator()
Gets theEscalatorused by this Grid instance.- Returns:
- the escalator instance, never
null
-
setHeight
public void setHeight(String height)
Note: This method will change the widget's size in the browser only if
getHeightMode()returnsHeightMode.CSS.- Overrides:
setHeightin classcom.google.gwt.user.client.ui.UIObject- See Also:
setHeightMode(HeightMode)
-
setWidth
public void setWidth(String width)
- Overrides:
setWidthin classcom.google.gwt.user.client.ui.UIObject
-
setDataSource
public void setDataSource(DataSource<T> dataSource) throws IllegalArgumentException
Sets the data source used by this grid.- Parameters:
dataSource- the data source to use, not null- Throws:
IllegalArgumentException- ifdataSourceisnull
-
getDataSource
public DataSource<T> getDataSource()
Gets the for this Grid.- Returns:
- the data source used by this grid
-
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.The default value is 0.
- Parameters:
numberOfColumns- the number of columns that should be frozen- Throws:
IllegalArgumentException- if the column count is < -1 or > 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 includes
hidden columnsin the count.- Returns:
- the number of frozen columns
-
addRowVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
-
scrollToRow
public void scrollToRow(int rowIndex) throws IllegalArgumentExceptionScrolls to a certain row, usingScrollDestination.ANY.If the details for that row are visible, those will be taken into account as well.
- Parameters:
rowIndex- zero-based index of the row to scroll to.- Throws:
IllegalArgumentException- if rowIndex is below zero, or above the maximum value supported by the data source.
-
scrollToRow
public void scrollToRow(int rowIndex, ScrollDestination destination) throws IllegalArgumentExceptionScrolls to a certain row, using user-specified scroll destination.If the details for that row are visible, those will be taken into account as well.
- Parameters:
rowIndex- zero-based index of the row to scroll to.destination- desired destination placement of scrolled-to-row. SeeScrollDestinationfor more information.- Throws:
IllegalArgumentException- if rowIndex is below zero, or above the maximum value supported by the data source.
-
scrollToStart
public void scrollToStart()
Scrolls to the beginning of the very first row.
-
scrollToEnd
public void scrollToEnd()
Scrolls to the end of the very last row.
-
setScrollTop
public void setScrollTop(double px)
Sets the vertical scroll offset.- Parameters:
px- the number of pixels this grid should be scrolled down
-
getScrollTop
public double getScrollTop()
Gets the vertical scroll offset.- Returns:
- the number of pixels this grid is scrolled down
-
setScrollLeft
public void setScrollLeft(double px)
Sets the horizontal scroll offset.- Parameters:
px- the number of pixels this grid should be scrolled right- Since:
- 7.5.0
-
getScrollLeft
public double getScrollLeft()
Gets the horizontal scroll offset.- Returns:
- the number of pixels this grid is scrolled to the right
-
getScrollHeight
public double getScrollHeight()
Returns the height of the scrollable area in pixels.- Returns:
- the height of the scrollable area in pixels
- Since:
- 7.5.0
-
getScrollWidth
public double getScrollWidth()
Returns the width of the scrollable area in pixels.- Returns:
- the width of the scrollable area in pixels.
- Since:
- 7.5.0
-
setHeightByRows
public void setHeightByRows(double rows) throws IllegalArgumentExceptionSets the number of rows that should be visible in Grid's body, whilegetHeightMode()isHeightMode.ROW.If Grid is currently not in
HeightMode.ROW, the given value is remembered, and applied once the mode is applied.- 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- See Also:
setHeightMode(HeightMode)
-
getHeightByRows
public double getHeightByRows()
Gets the amount of rows in Grid's body that are shown, whilegetHeightMode()isHeightMode.ROW.By default, it is .
- Returns:
- the amount of rows that should be shown in Grid's body, while in
HeightMode.ROW. - See Also:
setHeightByRows(double)
-
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 viasetHeight(String), and behave as a traditional Widget.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
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- Specified by:
onBrowserEventin interfacecom.google.gwt.user.client.EventListener- Overrides:
onBrowserEventin classcom.google.gwt.user.client.ui.Composite
-
getSubPartElement
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
- Specified by:
getSubPartElementin interfaceSubPartAware
-
getSubPartName
public String getSubPartName(com.google.gwt.user.client.Element subElement)
- Specified by:
getSubPartNamein interfaceSubPartAware
-
setSelectionModel
public void setSelectionModel(SelectionModel<T> selectionModel)
Sets the current selection model.This function will call
SelectionModel.setGrid(Grid).- Parameters:
selectionModel- a selection model implementation.- Throws:
IllegalArgumentException- if selection model argument is null
-
getSelectionModel
public SelectionModel<T> getSelectionModel()
Gets a reference to the current selection model.- Returns:
- the currently used SelectionModel instance.
-
setSelectionMode
public void setSelectionMode(Grid.SelectionMode mode)
Sets current selection mode.This is a shorthand method for
setSelectionModel(com.vaadin.v7.client.widget.grid.selection.SelectionModel<T>).- Parameters:
mode- a selection mode value- See Also:
Grid.SelectionMode
-
isSelected
public boolean isSelected(T row)
Test if a row is selected.- Parameters:
row- a row object- Returns:
- true, if the current selection model considers the provided row object selected.
-
select
public boolean select(T row)
Select a row using the current selection model.Only selection models implementing
SelectionModel.SingleandSelectionModel.Multiare supported; for anything else, an exception will be thrown.- Parameters:
row- a row object- Returns:
trueif the current selection changed- Throws:
IllegalStateException- if the current selection model is not an instance ofSelectionModel.SingleorSelectionModel.Multi
-
deselect
public boolean deselect(T row)
Deselect a row using the current selection model.Only selection models implementing
SelectionModel.SingleandSelectionModel.Multiare supported; for anything else, an exception will be thrown.- Parameters:
row- a row object- Returns:
trueif the current selection changed- Throws:
IllegalStateException- if the current selection model is not an instance ofSelectionModel.SingleorSelectionModel.Multi
-
deselectAll
public boolean deselectAll()
Deselect all rows using the current selection model.- Returns:
trueif the current selection changed- Throws:
IllegalStateException- if the current selection model is not an instance ofSelectionModel.SingleorSelectionModel.Multi
-
getSelectedRow
public T getSelectedRow()
Gets last selected row from the current SelectionModel.Only selection models implementing
SelectionModel.Singleare valid for this method; for anything else, use thegetSelectedRows()method.- Returns:
- a selected row reference, or null, if no row is selected
- Throws:
IllegalStateException- if the current selection model is not an instance ofSelectionModel.Single
-
getSelectedRows
public Collection<T> getSelectedRows()
Gets currently selected rows from the current selection model.- Returns:
- a non-null collection containing all currently selected rows.
-
addSelectionHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(SelectionHandler<T> handler)
Description copied from interface:HasSelectionHandlersRegister a selection change handler.This handler is called whenever a
SelectionModeldetects a change in selection state.- Specified by:
addSelectionHandlerin interfaceHasSelectionHandlers<T>- Parameters:
handler- aSelectionHandler- Returns:
- a handler registration object, which can be used to remove the handler.
-
sort
public void sort(Sort s)
Sets the current sort order using the fluid Sort API. Read the documentation forSortfor more information.- Parameters:
s- a sort instance
-
sort
public <C> void sort(Grid.Column<C,T> column)
Sorts the Grid data in ascending order along one column.- Parameters:
column- a grid column reference
-
sort
public <C> void sort(Grid.Column<C,T> column, com.vaadin.shared.data.sort.SortDirection direction)
Sorts the Grid data along one column.- Parameters:
column- a grid column referencedirection- a sort direction value
-
setSortOrder
public void setSortOrder(List<SortOrder> order)
Sets the sort order to use. Setting this causes the Grid to re-sort itself.- Parameters:
order- a sort order list. If set to null, the sort order is cleared.
-
getSortOrder
public List<SortOrder> getSortOrder()
Get a copy of the current sort order array.- Returns:
- a copy of the current sort order array
-
addSortHandler
public com.google.gwt.event.shared.HandlerRegistration addSortHandler(SortHandler<T> handler)
Register a GWT event handler for a sorting event. This handler gets called whenever this Grid needs its data source to provide data sorted in a specific order.- Parameters:
handler- a sort event handler- Returns:
- the registration for the event
-
addSelectAllHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectAllHandler(SelectAllHandler<T> handler)
Register a GWT event handler for a select all event. This handler gets called whenever Grid needs all rows selected.- Parameters:
handler- a select all event handler
-
addDataAvailableHandler
public com.google.gwt.event.shared.HandlerRegistration addDataAvailableHandler(DataAvailableHandler handler)
Register a GWT event handler for a data available event. This handler gets called whenever theDataSourcefor this Grid has new data available.This handle will be fired with the current available data after registration is done.
- Parameters:
handler- a data available event handler- Returns:
- the registartion for the event
-
addBodyKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyDownHandler(BodyKeyDownHandler handler)
Register a BodyKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Body of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addBodyKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyUpHandler(BodyKeyUpHandler handler)
Register a BodyKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Body of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addBodyKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyPressHandler(BodyKeyPressHandler handler)
Register a BodyKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Body of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyDownHandler(HeaderKeyDownHandler handler)
Register a HeaderKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Header of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyUpHandler(HeaderKeyUpHandler handler)
Register a HeaderKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Header of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyPressHandler(HeaderKeyPressHandler handler)
Register a HeaderKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Header of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyDownHandler(FooterKeyDownHandler handler)
Register a FooterKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyUpHandler(FooterKeyUpHandler handler)
Register a FooterKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyPressHandler(FooterKeyPressHandler handler)
Register a FooterKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler- the key handler to register- Returns:
- the registration for the event
-
addBodyClickHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyClickHandler(BodyClickHandler handler)
Register a BodyClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Body of this Grid.- Parameters:
handler- the click handler to register- Returns:
- the registration for the event
-
addHeaderClickHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderClickHandler(HeaderClickHandler handler)
Register a HeaderClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Header of this Grid.- Parameters:
handler- the click handler to register- Returns:
- the registration for the event
-
addFooterClickHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterClickHandler(FooterClickHandler handler)
Register a FooterClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Footer of this Grid.- Parameters:
handler- the click handler to register- Returns:
- the registration for the event
-
addBodyDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyDoubleClickHandler(BodyDoubleClickHandler handler)
Register a BodyDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Body of this Grid.- Parameters:
handler- the double click handler to register- Returns:
- the registration for the event
-
addHeaderDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderDoubleClickHandler(HeaderDoubleClickHandler handler)
Register a HeaderDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Header of this Grid.- Parameters:
handler- the double click handler to register- Returns:
- the registration for the event
-
addFooterDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterDoubleClickHandler(FooterDoubleClickHandler handler)
Register a FooterDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Footer of this Grid.- Parameters:
handler- the double click handler to register- Returns:
- the registration for the event
-
addColumnReorderHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnReorderHandler(ColumnReorderHandler<T> handler)
Register a column reorder handler to this Grid. The event for this handler is fired when the Grid's columns are reordered.- Parameters:
handler- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.5.0
-
addColumnVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnVisibilityChangeHandler(ColumnVisibilityChangeHandler<T> handler)
Register a column visibility change handler to this Grid. The event for this handler is fired when the Grid's columns change visibility.- Parameters:
handler- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.5.0
-
addColumnResizeHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnResizeHandler(ColumnResizeHandler<T> handler)
Register a column resize handler to this Grid. The event for this handler is fired when the Grid's columns are resized.- Parameters:
handler- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.6
-
addEnabledHandler
public com.google.gwt.event.shared.HandlerRegistration addEnabledHandler(GridEnabledHandler handler)
Register a enabled status change handler to this Grid. The event for this handler is fired when the Grid changes from disabled to enabled and vice-versa.- Parameters:
handler- the handler for the event- Returns:
- the registration for the event
-
addRowHeightChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addRowHeightChangedHandler(RowHeightChangedHandler handler)
-
addSpacerVisibilityChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addSpacerVisibilityChangedHandler(SpacerVisibilityChangedHandler handler)
Adds a spacer visibility changed handler to the underlying escalator.- Parameters:
handler- the handler to be called when a spacer's visibility changes- Returns:
- the registration object with which the handler can be removed
- Since:
- 7.7.13
-
addBrowserEventHandler
public void addBrowserEventHandler(int index, GridEventHandler<T> handler)Adds a low-level DOM event handler to this Grid. The handler is inserted into the given position in the list of handlers. The handlers are invoked in order. If theonEventmethod of a handler returns true, subsequent handlers are not invoked.- Parameters:
index- the index to insert the handler tohandler- the handler to add
-
addScrollHandler
public com.google.gwt.event.shared.HandlerRegistration addScrollHandler(ScrollHandler handler)
Adds a scroll handler to this grid.- Parameters:
handler- the scroll handler to add- Returns:
- a handler registration for the registered scroll handler
-
isWorkPending
public boolean isWorkPending()
- Specified by:
isWorkPendingin interfaceDeferredWorker
-
isColumnReorderingAllowed
public boolean isColumnReorderingAllowed()
Returns whether columns can be reordered with drag and drop.- Returns:
trueif columns can be reordered, false otherwise- Since:
- 7.5.0
-
setColumnReorderingAllowed
public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether column reordering with drag and drop is allowed or not.- Parameters:
columnReorderingAllowed- specifies whether column reordering is allowed- Since:
- 7.5.0
-
setColumnOrder
public void setColumnOrder(Grid.Column<?,T>... orderedColumns)
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:
orderedColumns- array of columns in wanted order
-
setCellStyleGenerator
public void setCellStyleGenerator(CellStyleGenerator<T> cellStyleGenerator)
Sets the style generator that is used for generating styles for cells.- Parameters:
cellStyleGenerator- the cell style generator to set, ornullto remove a previously set generator
-
getCellStyleGenerator
public CellStyleGenerator<T> getCellStyleGenerator()
Gets the style generator that is used for generating styles for cells.- Returns:
- the cell style generator, or
nullif no generator is set
-
setRowStyleGenerator
public void setRowStyleGenerator(RowStyleGenerator<T> rowStyleGenerator)
Sets the style generator that is used for generating styles for rows.- Parameters:
rowStyleGenerator- the row style generator to set, ornullto remove a previously set generator
-
getRowStyleGenerator
public RowStyleGenerator<T> getRowStyleGenerator()
Gets the style generator that is used for generating styles for rows.- Returns:
- the row style generator, or
nullif no generator is set
-
editRow
public void editRow(int rowIndex)
Opens the editor over the row with the given index.- Parameters:
rowIndex- the index of the row to be edited- Throws:
IllegalStateException- if the editor is not enabledIllegalStateException- if the editor is already in edit mode
-
isEditorActive
public boolean isEditorActive()
Returns whether the editor is currently open on some row.- Returns:
trueif the editor is active,falseotherwise.
-
saveEditor
public void saveEditor()
Saves any unsaved changes in the editor to the data source.- Throws:
IllegalStateException- if the editor is not enabledIllegalStateException- if the editor is not in edit mode
-
cancelEditor
public void cancelEditor()
Cancels the currently active edit and hides the editor. Any changes that are notsavedare lost.- Throws:
IllegalStateException- if the editor is not enabledIllegalStateException- if the editor is not in edit mode
-
getEditorHandler
public EditorHandler<T> getEditorHandler()
Returns the handler responsible for binding data and editor widgets to the editor.- Returns:
- the editor handler or null if not set
-
setEditorHandler
public void setEditorHandler(EditorHandler<T> handler)
Sets the handler responsible for binding data and editor widgets to the editor.- Parameters:
handler- the new editor handler- Throws:
IllegalStateException- if the editor is currently in edit mode
-
isEditorEnabled
public boolean isEditorEnabled()
Returns the enabled state of the editor.- Returns:
- true if editing is enabled, false otherwise
-
setEditorEnabled
public void setEditorEnabled(boolean enabled)
Sets the enabled state of the editor.- Parameters:
enabled- true to enable editing, false to disable- Throws:
IllegalStateException- if in edit mode and trying to disableIllegalStateException- if the editor handler is not set
-
getEditorWidget
public com.google.gwt.user.client.ui.Widget getEditorWidget(Grid.Column<?,T> column)
Returns the editor widget associated with the given column. If the editor is not active, returns null.- Parameters:
column- the column- Returns:
- the widget if the editor is open, null otherwise
-
setEditorSaveCaption
public void setEditorSaveCaption(String saveCaption) throws IllegalArgumentException
Sets the caption on the save button in the Grid editor.- Parameters:
saveCaption- the caption to set- Throws:
IllegalArgumentException- ifsaveCaptionisnull
-
getEditorSaveCaption
public String getEditorSaveCaption()
Gets the current caption on the save button in the Grid editor.- Returns:
- the current caption on the save button
-
setEditorCancelCaption
public void setEditorCancelCaption(String cancelCaption) throws IllegalArgumentException
Sets the caption on the cancel button in the Grid editor.- Parameters:
cancelCaption- the caption to set- Throws:
IllegalArgumentException- ifcancelCaptionisnull
-
getEditorCancelCaption
public String getEditorCancelCaption()
Gets the caption on the cancel button in the Grid editor.- Returns:
- the current caption on the cancel button
-
onAttach
protected void onAttach()
- Overrides:
onAttachin classcom.google.gwt.user.client.ui.Composite
-
onDetach
protected void onDetach()
- Overrides:
onDetachin classcom.google.gwt.user.client.ui.Composite
-
onResize
public void onResize()
- Specified by:
onResizein interfacecom.google.gwt.user.client.ui.RequiresResize- Overrides:
onResizein classcom.google.gwt.user.client.ui.ResizeComposite
-
add
@Deprecated public void add(com.google.gwt.user.client.ui.Widget w)
Deprecated.Grid does not support adding Widgets this way.This method is implemented only because removing widgets from Grid (added via e.g.
Renderers) requires theHasWidgetsinterface.- Specified by:
addin interfacecom.google.gwt.user.client.ui.HasWidgets- Parameters:
w- irrelevant- Throws:
UnsupportedOperationException- always
-
clear
@Deprecated public void clear()
Deprecated.Grid does not support clearing Widgets this way.This method is implemented only because removing widgets from Grid (added via e.g.
Renderers) requires theHasWidgetsinterface.- Specified by:
clearin interfacecom.google.gwt.user.client.ui.HasWidgets- Throws:
UnsupportedOperationException- always
-
iterator
@Deprecated public Iterator<com.google.gwt.user.client.ui.Widget> iterator()
Deprecated.Grid does not support iterating through Widgets this way.This method is implemented only because removing widgets from Grid (added via e.g.
Renderers) requires theHasWidgetsinterface.- Specified by:
iteratorin interfacecom.google.gwt.user.client.ui.HasWidgets- Specified by:
iteratorin interfaceIterable<T>- Returns:
- never
- Throws:
UnsupportedOperationException- always
-
remove
@Deprecated public boolean remove(com.google.gwt.user.client.ui.Widget w)
Deprecated.Grid does not support removing Widgets this way.This method is implemented only because removing widgets from Grid (added via e.g.
Renderers) requires theHasWidgetsinterface.- Specified by:
removein interfacecom.google.gwt.user.client.ui.HasWidgets- Returns:
- always
false
-
doAttachChildren
protected void doAttachChildren()
- Overrides:
doAttachChildrenin classcom.google.gwt.user.client.ui.Widget
-
doDetachChildren
protected void doDetachChildren()
- Overrides:
doDetachChildrenin classcom.google.gwt.user.client.ui.Widget
-
resetSizesFromDom
public void resetSizesFromDom()
Resets all cached pixel sizes and reads new values from the DOM. This methods should be used e.g. when styles affecting the dimensions of elements in this grid have been changed.
-
setDetailsGenerator
public void setDetailsGenerator(DetailsGenerator detailsGenerator) throws IllegalArgumentException
Sets a new details generator for row details.The currently opened row details will be re-rendered.
- Parameters:
detailsGenerator- the details generator to set- Throws:
IllegalArgumentException- if detailsGenerator isnull;- Since:
- 7.5.0
-
getDetailsGenerator
public DetailsGenerator getDetailsGenerator()
Gets the current details generator for row details.- Returns:
- the detailsGenerator the current details generator
- Since:
- 7.5.0
-
setDetailsVisible
public void setDetailsVisible(int rowIndex, boolean visible)Shows or hides the details for a specific row.This method does nothing if trying to set show already-visible details, or hide already-hidden details.
- Parameters:
rowIndex- the index of the affected rowvisible-trueto show the details, orfalseto hide them- Since:
- 7.5.0
- See Also:
isDetailsVisible(int)
-
isDetailsVisible
public boolean isDetailsVisible(int rowIndex)
Check whether the details for a row is visible or not.- Parameters:
rowIndex- the index of the row for which to check details- Returns:
trueif the details for the given row is visible- Since:
- 7.5.0
- See Also:
setDetailsVisible(int, boolean)
-
setDetailsHeight
public void setDetailsHeight(int rowIndex, double height)Update details row height.- Parameters:
rowIndex- the index of the row for which to update details heightheight- new height of the details row- Since:
- 7.7.11
-
recalculateColumnWidths
public void recalculateColumnWidths()
Requests that the column widths should be recalculated.The actual recalculation is not necessarily done immediately so you cannot rely on the columns being the correct width after the call returns.
- Since:
- 7.4.1
-
getSidebarMenu
public com.google.gwt.user.client.ui.MenuBar getSidebarMenu()
Gets the customizable menu bar that is by default used for toggling column hidability. The application developer is allowed to add their custom items to the end of the menu, but should try to avoid modifying the items in the beginning of the menu that control the column hiding if any columns are marked as hidable. A toggle for opening the menu will be displayed whenever the menu contains at least one item.- Returns:
- the menu bar
- Since:
- 7.5.0
-
isSidebarOpen
public boolean isSidebarOpen()
Tests whether the sidebar menu is currently open.- Returns:
trueif the sidebar is open;falseif it is closed- Since:
- 7.5.0
- See Also:
getSidebarMenu()
-
setSidebarOpen
public void setSidebarOpen(boolean sidebarOpen)
Sets whether the sidebar menu is open.- Parameters:
sidebarOpen-trueto open the sidebar;falseto close it- Since:
- 7.5.0
- See Also:
getSidebarMenu(),isSidebarOpen()
-
getTabIndex
public int getTabIndex()
- Specified by:
getTabIndexin interfacecom.google.gwt.user.client.ui.Focusable
-
setAccessKey
public void setAccessKey(char key)
- Specified by:
setAccessKeyin interfacecom.google.gwt.user.client.ui.Focusable
-
setFocus
public void setFocus(boolean focused)
- Specified by:
setFocusin interfacecom.google.gwt.user.client.ui.Focusable
-
setTabIndex
public void setTabIndex(int index)
- Specified by:
setTabIndexin interfacecom.google.gwt.user.client.ui.Focusable
-
setEditorBuffered
public void setEditorBuffered(boolean editorBuffered)
Sets the buffered editor mode.- Parameters:
editorBuffered-trueto enable buffered editor,falseto disable it- Since:
- 7.6
-
isEditorBuffered
public boolean isEditorBuffered()
Gets the buffered editor mode.- Returns:
trueif buffered editor is enabled,falseotherwise- Since:
- 7.6
-
getEventCell
public EventCellReference<T> getEventCell()
Returns theEventCellReferencefor the latest event fired from this Grid.Note: This cell reference will be updated when firing the next event.
- Returns:
- event cell reference
- Since:
- 7.5
-
getCellReference
public CellReference<T> getCellReference(com.google.gwt.dom.client.Element element)
Returns a CellReference for the cell to which the given element belongs to.- Parameters:
element- Element to find from the cell's content.- Returns:
- CellReference or
nullif cell was not found. - Since:
- 7.6
-
isUserSelectionAllowed
public boolean isUserSelectionAllowed()
Checks if selection by the user is allowed in the grid.- Returns:
trueif selection by the user is allowed by the selection model (the default),falseotherwise- Since:
- 7.7.7
-
-