T
- The row type of the grid. The row type is the POJO type from where
the data is retrieved into the column cells.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
Each column in Grid is represented by a Grid.Column
. Each
GridColumn
has a custom implementation for
Grid.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 GridColumn
and display it to the user. A simple column
might have a TextRenderer
that simply takes in a String
and
displays it as the cell's content. A more complex renderer might be
ProgressBarRenderer
that takes in a floating point number, and
displays a progress bar instead, based on the given number.
See: addColumn(Column)
, addColumn(Column, int)
and
addColumns(Column...)
. Also
Grid.Column.setRenderer(Renderer)
.
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 (see AbstractRemoteDataSource
).
Modifier and Type | Class and Description |
---|---|
static class |
Grid.AbstractGridKeyEvent<HANDLER extends AbstractGridKeyEventHandler> |
static class |
Grid.AbstractGridMouseEvent<HANDLER extends AbstractGridMouseEventHandler> |
protected class |
Grid.BodyUpdater |
static class |
Grid.Column<C,T>
Base class for grid columns internally used by the Grid.
|
static class |
Grid.Editor<T>
An editor UI for Grid rows.
|
static class |
Grid.EditorDomEvent<T>
A wrapper for native DOM events related to the
Grid editor
. |
protected static class |
Grid.Footer
Represents the footer section of a Grid.
|
static class |
Grid.FooterCell
A single cell in a grid Footer row.
|
static class |
Grid.FooterRow
A single row in a grid Footer section.
|
static class |
Grid.GridEvent<T>
A wrapper for native DOM events originating from Grid.
|
protected static class |
Grid.Header
Represents the header section of a Grid.
|
static class |
Grid.HeaderCell
A single cell in a grid header row.
|
static class |
Grid.HeaderRow
A single row in a grid header section.
|
class |
Grid.SelectionColumn |
static class |
Grid.SelectionMode
Enumeration for easy setting of selection mode.
|
static class |
Grid.StaticSection<ROWTYPE extends Grid.StaticSection.StaticRow<?>>
Abstract base class for Grid header and footer sections.
|
protected class |
Grid.StaticSectionUpdater |
Modifier and Type | Field and Description |
---|---|
protected com.vaadin.client.widgets.Grid.CellFocusHandler |
cellFocusHandler |
Constructor and Description |
---|
Grid()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(com.google.gwt.user.client.ui.Widget w)
Deprecated.
|
com.google.gwt.event.shared.HandlerRegistration |
addBodyClickHandler(BodyClickHandler handler)
Register a BodyClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addBodyDoubleClickHandler(BodyDoubleClickHandler handler)
Register a BodyDoubleClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addBodyKeyDownHandler(BodyKeyDownHandler handler)
Register a BodyKeyDownHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addBodyKeyPressHandler(BodyKeyPressHandler handler)
Register a BodyKeyPressHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addBodyKeyUpHandler(BodyKeyUpHandler handler)
Register a BodyKeyUpHandler to this Grid.
|
void |
addBrowserEventHandler(int index,
GridEventHandler<T> handler)
Adds a low-level DOM event handler to this Grid.
|
<C extends Grid.Column<?,T>> |
addColumn(C column)
Adds a column as the last column in the grid.
|
<C extends Grid.Column<?,T>> |
addColumn(C column,
int index)
Inserts a column into a specific position in the grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addColumnReorderHandler(ColumnReorderHandler<T> handler)
Register a column reorder handler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addColumnResizeHandler(ColumnResizeHandler<T> handler)
Register a column resize handler to this Grid.
|
void |
addColumns(Grid.Column<?,T>... columns)
Adds columns as the last columns in the grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addColumnVisibilityChangeHandler(ColumnVisibilityChangeHandler<T> handler)
Register a column visibility change handler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addDataAvailableHandler(DataAvailableHandler handler)
Register a GWT event handler for a data available event.
|
com.google.gwt.event.shared.HandlerRegistration |
addEnabledHandler(GridEnabledHandler handler)
Register a enabled status change handler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addFooterClickHandler(FooterClickHandler handler)
Register a FooterClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addFooterDoubleClickHandler(FooterDoubleClickHandler handler)
Register a FooterDoubleClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addFooterKeyDownHandler(FooterKeyDownHandler handler)
Register a FooterKeyDownHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addFooterKeyPressHandler(FooterKeyPressHandler handler)
Register a FooterKeyPressHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addFooterKeyUpHandler(FooterKeyUpHandler handler)
Register a FooterKeyUpHandler to this Grid.
|
Grid.FooterRow |
addFooterRowAt(int index)
Inserts a new row at the given position to the footer section.
|
com.google.gwt.event.shared.HandlerRegistration |
addHeaderClickHandler(HeaderClickHandler handler)
Register a HeaderClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addHeaderDoubleClickHandler(HeaderDoubleClickHandler handler)
Register a HeaderDoubleClickHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addHeaderKeyDownHandler(HeaderKeyDownHandler handler)
Register a HeaderKeyDownHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addHeaderKeyPressHandler(HeaderKeyPressHandler handler)
Register a HeaderKeyPressHandler to this Grid.
|
com.google.gwt.event.shared.HandlerRegistration |
addHeaderKeyUpHandler(HeaderKeyUpHandler handler)
Register a HeaderKeyUpHandler to this Grid.
|
Grid.HeaderRow |
addHeaderRowAt(int index)
Inserts a new row at the given position to the header section.
|
com.google.gwt.event.shared.HandlerRegistration |
addRowHeightChangedHandler(RowHeightChangedHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addScrollHandler(ScrollHandler handler)
Adds a scroll handler to this grid
|
com.google.gwt.event.shared.HandlerRegistration |
addSelectAllHandler(SelectAllHandler<T> handler)
Register a GWT event handler for a select all event.
|
com.google.gwt.event.shared.HandlerRegistration |
addSelectionHandler(SelectionHandler<T> handler)
Register a selection change handler.
|
com.google.gwt.event.shared.HandlerRegistration |
addSortHandler(SortHandler<T> handler)
Register a GWT event handler for a sorting event.
|
com.google.gwt.event.shared.HandlerRegistration |
addSpacerVisibilityChangedHandler(SpacerVisibilityChangedHandler handler)
Adds a spacer visibility changed handler to the underlying escalator.
|
Grid.FooterRow |
appendFooterRow()
Adds a new row at the bottom of the footer section.
|
Grid.HeaderRow |
appendHeaderRow()
Adds a new row at the bottom of the header section.
|
void |
cancelEditor()
Cancels the currently active edit and hides the editor.
|
void |
clear()
Deprecated.
|
protected EscalatorUpdater |
createBodyUpdater()
Creates the escalator updater used to update the body rows in this grid.
|
protected EscalatorUpdater |
createFooterUpdater()
Creates the escalator updater used to update the footer rows in this
grid.
|
protected EscalatorUpdater |
createHeaderUpdater()
Creates the escalator updater used to update the header rows in this
grid.
|
boolean |
deselect(T row)
Deselect a row using the current selection model.
|
boolean |
deselectAll()
Deselect all rows using the current selection model.
|
protected void |
doAttachChildren() |
protected void |
doDetachChildren() |
void |
editRow(int rowIndex)
Opens the editor over the row with the given index.
|
void |
focus()
Sets focus to this widget.
|
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.
|
int |
getColumnCount()
Returns the amount of columns in the grid.
|
ColumnResizeMode |
getColumnResizeMode()
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.HeaderRow |
getDefaultHeaderRow()
Returns the current default row of the header section.
|
DetailsGenerator |
getDetailsGenerator()
Gets the current details generator for row details.
|
Grid.Editor<T> |
getEditor() |
String |
getEditorCancelCaption()
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.
|
String |
getEditorSaveCaption()
Gets the current caption on the save button in the Grid editor.
|
com.google.gwt.user.client.ui.Widget |
getEditorWidget(Grid.Column<?,T> column)
Returns the editor widget associated with the given column.
|
Escalator |
getEscalator()
Gets the
Escalator used by this Grid instnace. |
EventCellReference<T> |
getEventCell()
Returns the
EventCellReference for the latest event fired from
this Grid. |
protected Grid.Footer |
getFooter()
Returns the footer section of this grid.
|
Grid.FooterRow |
getFooterRow(int rowIndex)
Gets the footer row at given index.
|
int |
getFooterRowCount()
Gets the row count for the footer.
|
int |
getFrozenColumnCount()
Gets the number of frozen columns in this grid.
|
protected Grid.Header |
getHeader()
Returns the header section of this grid.
|
Grid.HeaderRow |
getHeaderRow(int rowIndex)
Gets the header row at given index.
|
int |
getHeaderRowCount()
Gets the row count for the header section.
|
double |
getHeightByRows()
Gets the amount of rows in Grid's body that are shown, while
getHeightMode() is HeightMode.ROW . |
HeightMode |
getHeightMode()
Returns the current
HeightMode the Grid is in. |
RowStyleGenerator<T> |
getRowStyleGenerator()
Gets the style generator that is used for generating styles for rows
|
double |
getScrollHeight()
Returns the height of the scrollable area in pixels.
|
double |
getScrollLeft()
Gets the horizontal scroll offset
|
double |
getScrollTop()
Gets the vertical scroll offset
|
double |
getScrollWidth()
Returns the width of the scrollable area in pixels.
|
T |
getSelectedRow()
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.MenuBar |
getSidebarMenu()
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.Element |
getSubPartElement(String subPart)
Locates an element inside a component using the identifier provided in
subPart . |
String |
getSubPartName(com.google.gwt.user.client.Element subElement)
Provides an identifier that identifies the element within the component.
|
int |
getTabIndex() |
List<Grid.Column<?,T>> |
getVisibleColumns()
Returns a list of the currently visible columns in the grid.
|
boolean |
isColumnReorderingAllowed()
Returns whether columns can be reordered with drag and drop.
|
boolean |
isDetailsVisible(int rowIndex)
Check whether the details for a row is visible or not.
|
boolean |
isEditorActive()
Returns whether the editor is currently open on some row.
|
boolean |
isEditorBuffered()
Gets the buffered editor mode.
|
boolean |
isEditorEnabled()
Returns the enabled state of the editor.
|
boolean |
isEnabled() |
boolean |
isFooterVisible()
Returns the visibility of the footer section.
|
boolean |
isHeaderVisible()
Returns the visibility of the header section.
|
boolean |
isSelected(T row)
Test if a row is selected.
|
boolean |
isSidebarOpen()
Tests whether the sidebar menu is currently open.
|
boolean |
isUserSelectionAllowed()
Checks if selection by the user is allowed in the grid.
|
boolean |
isWorkPending()
Checks whether there are operations pending for this widget or connector
that must be executed before reaching a steady state.
|
Iterator<com.google.gwt.user.client.ui.Widget> |
iterator()
Deprecated.
|
protected void |
onAttach() |
void |
onBrowserEvent(com.google.gwt.user.client.Event event) |
protected void |
onDetach() |
void |
onResize() |
Grid.FooterRow |
prependFooterRow()
Adds a new row at the top of the footer section.
|
Grid.HeaderRow |
prependHeaderRow()
Adds a new row at the top of the header section.
|
void |
recalculateColumnWidths()
Requests that the column widths should be recalculated.
|
boolean |
remove(com.google.gwt.user.client.ui.Widget w)
Deprecated.
|
void |
removeColumn(Grid.Column<?,T> column)
Removes a column from the grid.
|
void |
removeFooterRow(Grid.FooterRow row)
Removes the given row from the footer section.
|
void |
removeFooterRow(int rowIndex)
Removes the row at the given position from the footer section.
|
void |
removeHeaderRow(Grid.HeaderRow row)
Removes the given row from the header section.
|
void |
removeHeaderRow(int rowIndex)
Removes the row at the given position from the header section.
|
void |
resetSizesFromDom()
Resets all cached pixel sizes and reads new values from the DOM.
|
void |
saveEditor()
Saves any unsaved changes in the editor to the data source.
|
void |
scrollToEnd()
Scrolls to the end of the very last row.
|
void |
scrollToRow(int rowIndex)
Scrolls to a certain row, using
ScrollDestination.ANY . |
void |
scrollToRow(int rowIndex,
ScrollDestination destination)
Scrolls to a certain row, using user-specified scroll destination.
|
void |
scrollToStart()
Scrolls to the beginning of the very first row.
|
boolean |
select(T row)
Select a row using the current selection model.
|
void |
setAccessKey(char key) |
void |
setCellStyleGenerator(CellStyleGenerator<T> cellStyleGenerator)
Sets the style generator that is used for generating styles for cells
|
void |
setColumnOrder(Grid.Column<?,T>... orderedColumns)
Sets a new column order for the grid.
|
void |
setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether column reordering with drag and drop is allowed or not.
|
void |
setColumnResizeMode(ColumnResizeMode mode)
Sets the column resize mode to use.
|
void |
setDataSource(DataSource<T> dataSource)
Sets the data source used by this grid.
|
void |
setDefaultHeaderRow(Grid.HeaderRow row)
Sets the default row of the header.
|
void |
setDetailsGenerator(DetailsGenerator detailsGenerator)
Sets a new details generator for row details.
|
void |
setDetailsHeight(int rowIndex,
double height)
Update details row height.
|
void |
setDetailsVisible(int rowIndex,
boolean visible)
Shows or hides the details for a specific row.
|
void |
setEditorBuffered(boolean editorBuffered)
Sets the buffered editor mode.
|
void |
setEditorCancelCaption(String cancelCaption)
Sets the caption on the cancel button in the Grid editor.
|
void |
setEditorEnabled(boolean enabled)
Sets the enabled state of the editor.
|
void |
setEditorHandler(EditorHandler<T> handler)
Sets the handler responsible for binding data and editor widgets to the
editor.
|
void |
setEditorSaveCaption(String saveCaption)
Sets the caption on the save button in the Grid editor.
|
void |
setEnabled(boolean enabled) |
void |
setFocus(boolean focused) |
void |
setFooterVisible(boolean visible)
Sets the visibility of the footer section.
|
void |
setFrozenColumnCount(int numberOfColumns)
Sets the number of frozen columns in this grid.
|
void |
setHeaderVisible(boolean visible)
Sets the visibility of the header section.
|
void |
setHeight(String height) |
void |
setHeightByRows(double rows)
Sets the number of rows that should be visible in Grid's body, while
getHeightMode() is HeightMode.ROW . |
void |
setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.
|
void |
setRowStyleGenerator(RowStyleGenerator<T> rowStyleGenerator)
Sets the style generator that is used for generating styles for rows
|
void |
setScrollLeft(double px)
Sets the horizontal scroll offset
|
void |
setScrollTop(double px)
Sets the vertical scroll offset.
|
void |
setSelectionMode(Grid.SelectionMode mode)
Sets current selection mode.
|
void |
setSelectionModel(SelectionModel<T> selectionModel)
Sets the current selection model.
|
void |
setSidebarOpen(boolean sidebarOpen)
Sets whether the sidebar menu is open.
|
void |
setSortOrder(List<SortOrder> order)
Sets the sort order to use.
|
void |
setStylePrimaryName(String style) |
void |
setTabIndex(int index) |
void |
setWidth(String width) |
<C> void |
sort(Grid.Column<C,T> column)
Sorts the Grid data in ascending order along one column.
|
<C> void |
sort(Grid.Column<C,T> column,
SortDirection direction)
Sorts the Grid data along one column.
|
void |
sort(Sort s)
Sets the current sort order using the fluid Sort API.
|
claimElement, getWidget, initializeClaimedElement, isAttached, render, render, resolvePotentialElement, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected final com.vaadin.client.widgets.Grid.CellFocusHandler cellFocusHandler
public boolean isEnabled()
isEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
public void setEnabled(boolean enabled)
setEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
public void setColumnResizeMode(ColumnResizeMode mode)
ColumnResizeMode.ANIMATED
.mode
- a ColumnResizeMode valuepublic ColumnResizeMode getColumnResizeMode()
ColumnResizeMode.ANIMATED
.public void setStylePrimaryName(String style)
setStylePrimaryName
in class com.google.gwt.user.client.ui.UIObject
protected EscalatorUpdater createHeaderUpdater()
GridHeader
,
getHeader()
protected EscalatorUpdater createBodyUpdater()
protected EscalatorUpdater createFooterUpdater()
GridFooter
,
getFooter()
public void addColumns(Grid.Column<?,T>... columns)
columns
- the columns to addpublic <C extends Grid.Column<?,T>> C addColumn(C column)
column
- the column to addpublic <C extends Grid.Column<?,T>> C addColumn(C column, int index)
index
- the index where the column should be inserted intocolumn
- the column to addIllegalStateException
- if Grid's current selection model renders a selection column,
and index
is 0.public void removeColumn(Grid.Column<?,T> column)
column
- the column to removepublic int getColumnCount()
NOTE: this includes the hidden columns in the count.
public List<Grid.Column<?,T>> getColumns()
For currently visible columns, use getVisibleColumns()
.
public List<Grid.Column<?,T>> getVisibleColumns()
No hidden
columns included.
public Grid.Column<?,T> getColumn(int index) throws IllegalArgumentException
NOTE: The indexing includes hidden columns.
index
- the index of the columnIllegalArgumentException
- if the column index does not exist in the gridprotected Grid.Header getHeader()
public Grid.HeaderRow getHeaderRow(int rowIndex)
rowIndex
- 0 based index for row. Counted from top to bottomIllegalArgumentException
- if no row exists at given indexpublic Grid.HeaderRow addHeaderRowAt(int index)
index
- the position at which to insert the rowIllegalArgumentException
- if the index is less than 0 or greater than row countappendHeaderRow()
,
prependHeaderRow()
,
removeHeaderRow(HeaderRow)
,
removeHeaderRow(int)
public Grid.HeaderRow appendHeaderRow()
prependHeaderRow()
,
addHeaderRowAt(int)
,
removeHeaderRow(HeaderRow)
,
removeHeaderRow(int)
public Grid.HeaderRow getDefaultHeaderRow()
public int getHeaderRowCount()
public Grid.HeaderRow prependHeaderRow()
appendHeaderRow()
,
addHeaderRowAt(int)
,
removeHeaderRow(HeaderRow)
,
removeHeaderRow(int)
public void removeHeaderRow(Grid.HeaderRow row)
row
- the row to be removedIllegalArgumentException
- if the row does not exist in this sectionremoveHeaderRow(int)
,
addHeaderRowAt(int)
,
appendHeaderRow()
,
prependHeaderRow()
public void removeHeaderRow(int rowIndex)
index
- the position of the rowIllegalArgumentException
- if no row exists at given indexremoveHeaderRow(HeaderRow)
,
addHeaderRowAt(int)
,
appendHeaderRow()
,
prependHeaderRow()
public void setDefaultHeaderRow(Grid.HeaderRow row)
Note: Setting the default header row will reset all cell contents to Column defaults.
row
- the new default row, or null for no default rowIllegalArgumentException
- header does not contain the rowpublic void setHeaderVisible(boolean visible)
visible
- true to show header section, false to hidepublic boolean isHeaderVisible()
protected Grid.Footer getFooter()
public Grid.FooterRow getFooterRow(int rowIndex)
rowIndex
- 0 based index for row. Counted from top to bottomIllegalArgumentException
- if no row exists at given indexpublic Grid.FooterRow addFooterRowAt(int index)
index
- the position at which to insert the rowIllegalArgumentException
- if the index is less than 0 or greater than row countappendFooterRow()
,
prependFooterRow()
,
removeFooterRow(FooterRow)
,
removeFooterRow(int)
public Grid.FooterRow appendFooterRow()
prependFooterRow()
,
addFooterRowAt(int)
,
removeFooterRow(FooterRow)
,
removeFooterRow(int)
public int getFooterRowCount()
public Grid.FooterRow prependFooterRow()
appendFooterRow()
,
addFooterRowAt(int)
,
removeFooterRow(FooterRow)
,
removeFooterRow(int)
public void removeFooterRow(Grid.FooterRow row)
row
- the row to be removedIllegalArgumentException
- if the row does not exist in this sectionremoveFooterRow(int)
,
addFooterRowAt(int)
,
appendFooterRow()
,
prependFooterRow()
public void removeFooterRow(int rowIndex)
index
- the position of the rowIllegalArgumentException
- if no row exists at given indexremoveFooterRow(FooterRow)
,
addFooterRowAt(int)
,
appendFooterRow()
,
prependFooterRow()
public void setFooterVisible(boolean visible)
visible
- true to show footer section, false to hidepublic boolean isFooterVisible()
public Grid.Editor<T> getEditor()
public Escalator getEscalator()
Escalator
used by this Grid instnace.null
public void setHeight(String height)
Note: This method will change the widget's size in the browser
only if getHeightMode()
returns HeightMode.CSS
.
setHeight
in class com.google.gwt.user.client.ui.UIObject
setHeightMode(HeightMode)
public void setWidth(String width)
setWidth
in class com.google.gwt.user.client.ui.UIObject
public void setDataSource(DataSource<T> dataSource) throws IllegalArgumentException
dataSource
- the data source to use, not nullIllegalArgumentException
- if dataSource
is null
public DataSource<T> getDataSource()
public void setFrozenColumnCount(int numberOfColumns)
The default value is 0.
numberOfColumns
- the number of columns that should be frozenIllegalArgumentException
- if the column count is < -1 or > the number of visible
columnspublic int getFrozenColumnCount()
NOTE: This includes hidden columns
in
the count.
public com.google.gwt.event.shared.HandlerRegistration addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
public void scrollToRow(int rowIndex) throws IllegalArgumentException
ScrollDestination.ANY
.
If the details for that row are visible, those will be taken into account as well.
rowIndex
- zero-based index of the row to scroll to.IllegalArgumentException
- if rowIndex is below zero, or above the maximum value
supported by the data source.public void scrollToRow(int rowIndex, ScrollDestination destination) throws IllegalArgumentException
If the details for that row are visible, those will be taken into account as well.
rowIndex
- zero-based index of the row to scroll to.destination
- desired destination placement of scrolled-to-row. See
ScrollDestination
for more information.IllegalArgumentException
- if rowIndex is below zero, or above the maximum value
supported by the data source.public void scrollToStart()
public void scrollToEnd()
public void setScrollTop(double px)
px
- the number of pixels this grid should be scrolled downpublic double getScrollTop()
public void setScrollLeft(double px)
px
- the number of pixels this grid should be scrolled rightpublic double getScrollLeft()
public double getScrollHeight()
public double getScrollWidth()
public void setHeightByRows(double rows) throws IllegalArgumentException
getHeightMode()
is HeightMode.ROW
.
If Grid is currently not in HeightMode.ROW
, the given value is
remembered, and applied once the mode is applied.
rows
- The height in terms of number of rows displayed in Grid's
body. If Grid doesn't contain enough rows, white space is
displayed instead.IllegalArgumentException
- if rows
is zero or lessIllegalArgumentException
- if rows
is infinite
IllegalArgumentException
- if rows
is NaN
setHeightMode(HeightMode)
public double getHeightByRows()
getHeightMode()
is HeightMode.ROW
.
By default, it is .
HeightMode.ROW
.setHeightByRows(double)
public void setHeightMode(HeightMode heightMode)
If HeightMode.CSS
is given, Grid will respect the values given
via setHeight(String)
, and behave as a traditional Widget.
If HeightMode.ROW
is given, Grid will make sure that the body
will display as many rows as getHeightByRows()
defines.
Note: If headers/footers are inserted or removed, the widget
will resize itself to still display the required amount of rows in its
body. It also takes the horizontal scrollbar into account.
heightMode
- the mode in to which Grid should be setpublic HeightMode getHeightMode()
HeightMode
the Grid is in.
Defaults to HeightMode.CSS
.
public void onBrowserEvent(com.google.gwt.user.client.Event event)
onBrowserEvent
in interface com.google.gwt.user.client.EventListener
onBrowserEvent
in class com.google.gwt.user.client.ui.Composite
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
SubPartAware
subPart
. The subPart
identifier is component specific and
may be any string of characters, numbers, space characters and brackets.getSubPartElement
in interface SubPartAware
subPart
- The identifier for the element inside the componentpublic String getSubPartName(com.google.gwt.user.client.Element subElement)
SubPartAware
subElement
is a part of the component and must never be null.
Note!
getSubPartElement(getSubPartName(element)) == element
is not
always true. A component can choose to provide a more generic
identifier for any given element if the results of all interactions with
subElement
are the same as interactions with the element
identified by the return value. For example a button can return an
identifier for the root element even though a DIV inside the button was
passed as subElement
because interactions with the DIV and the
root button element produce the same result.
getSubPartName
in interface SubPartAware
subElement
- The element the identifier string should uniquely identifysubElement
or null
if no identifier could be provided.public void setSelectionModel(SelectionModel<T> selectionModel)
This function will call SelectionModel.setGrid(Grid)
.
selectionModel
- a selection model implementation.IllegalArgumentException
- if selection model argument is nullpublic SelectionModel<T> getSelectionModel()
public void setSelectionMode(Grid.SelectionMode mode)
This is a shorthand method for setSelectionModel(com.vaadin.client.widget.grid.selection.SelectionModel<T>)
.
mode
- a selection mode valueGrid.SelectionMode
public boolean isSelected(T row)
row
- a row objectpublic boolean select(T row)
Only selection models implementing SelectionModel.Single
and
SelectionModel.Multi
are supported; for anything else, an
exception will be thrown.
row
- a row objecttrue
iff the current selection changedIllegalStateException
- if the current selection model is not an instance of
SelectionModel.Single
or SelectionModel.Multi
public boolean deselect(T row)
Only selection models implementing SelectionModel.Single
and
SelectionModel.Multi
are supported; for anything else, an
exception will be thrown.
row
- a row objecttrue
iff the current selection changedIllegalStateException
- if the current selection model is not an instance of
SelectionModel.Single
or SelectionModel.Multi
public boolean deselectAll()
true
iff the current selection changedIllegalStateException
- if the current selection model is not an instance of
SelectionModel.Single
or SelectionModel.Multi
public T getSelectedRow()
Only selection models implementing SelectionModel.Single
are
valid for this method; for anything else, use the
getSelectedRows()
method.
IllegalStateException
- if the current selection model is not an instance of
SelectionModel.Single
public Collection<T> getSelectedRows()
public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(SelectionHandler<T> handler)
HasSelectionHandlers
This handler is called whenever a
SelectionModel
detects a change in selection state.
addSelectionHandler
in interface HasSelectionHandlers<T>
handler
- a SelectionHandler
public void sort(Sort s)
Sort
for more information.s
- a sort instancepublic <C> void sort(Grid.Column<C,T> column)
column
- a grid column referencepublic <C> void sort(Grid.Column<C,T> column, SortDirection direction)
column
- a grid column referencedirection
- a sort direction valuepublic void setSortOrder(List<SortOrder> order)
order
- a sort order list. If set to null, the sort order is cleared.public List<SortOrder> getSortOrder()
public com.google.gwt.event.shared.HandlerRegistration addSortHandler(SortHandler<T> handler)
handler
- a sort event handlerpublic com.google.gwt.event.shared.HandlerRegistration addSelectAllHandler(SelectAllHandler<T> handler)
handler
- a select all event handlerpublic com.google.gwt.event.shared.HandlerRegistration addDataAvailableHandler(DataAvailableHandler handler)
DataSource
for this Grid has new data
available.
This handle will be fired with the current available data after registration is done.
handler
- a data available event handlerpublic com.google.gwt.event.shared.HandlerRegistration addBodyKeyDownHandler(BodyKeyDownHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addBodyKeyUpHandler(BodyKeyUpHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addBodyKeyPressHandler(BodyKeyPressHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addHeaderKeyDownHandler(HeaderKeyDownHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addHeaderKeyUpHandler(HeaderKeyUpHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addHeaderKeyPressHandler(HeaderKeyPressHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addFooterKeyDownHandler(FooterKeyDownHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addFooterKeyUpHandler(FooterKeyUpHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addFooterKeyPressHandler(FooterKeyPressHandler handler)
handler
- the key handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addBodyClickHandler(BodyClickHandler handler)
handler
- the click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addHeaderClickHandler(HeaderClickHandler handler)
handler
- the click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addFooterClickHandler(FooterClickHandler handler)
handler
- the click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addBodyDoubleClickHandler(BodyDoubleClickHandler handler)
handler
- the double click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addHeaderDoubleClickHandler(HeaderDoubleClickHandler handler)
handler
- the double click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addFooterDoubleClickHandler(FooterDoubleClickHandler handler)
handler
- the double click handler to registerpublic com.google.gwt.event.shared.HandlerRegistration addColumnReorderHandler(ColumnReorderHandler<T> handler)
handler
- the handler for the eventpublic com.google.gwt.event.shared.HandlerRegistration addColumnVisibilityChangeHandler(ColumnVisibilityChangeHandler<T> handler)
handler
- the handler for the eventpublic com.google.gwt.event.shared.HandlerRegistration addColumnResizeHandler(ColumnResizeHandler<T> handler)
handler
- the handler for the eventpublic com.google.gwt.event.shared.HandlerRegistration addEnabledHandler(GridEnabledHandler handler)
handler
- the handler for the eventpublic com.google.gwt.event.shared.HandlerRegistration addRowHeightChangedHandler(RowHeightChangedHandler handler)
public com.google.gwt.event.shared.HandlerRegistration addSpacerVisibilityChangedHandler(SpacerVisibilityChangedHandler handler)
handler
- the handler to be called when a spacer's visibility changespublic void addBrowserEventHandler(int index, GridEventHandler<T> handler)
onEvent
method of a handler returns true, subsequent handlers are not invoked.index
- the index to insert the handler tohandler
- the handler to addpublic com.google.gwt.event.shared.HandlerRegistration addScrollHandler(ScrollHandler handler)
handler
- the scroll handler to addpublic boolean isWorkPending()
DeferredWorker
isWorkPending
in interface DeferredWorker
public boolean isColumnReorderingAllowed()
true
if columns can be reordered, false otherwisepublic void setColumnReorderingAllowed(boolean columnReorderingAllowed)
columnReorderingAllowed
- specifies whether column reordering is allowedpublic void setColumnOrder(Grid.Column<?,T>... orderedColumns)
orderedColumns
- array of columns in wanted orderpublic void setCellStyleGenerator(CellStyleGenerator<T> cellStyleGenerator)
cellStyleGenerator
- the cell style generator to set, or null
to
remove a previously set generatorpublic CellStyleGenerator<T> getCellStyleGenerator()
null
if no generator is
setpublic void setRowStyleGenerator(RowStyleGenerator<T> rowStyleGenerator)
rowStyleGenerator
- the row style generator to set, or null
to remove
a previously set generatorpublic RowStyleGenerator<T> getRowStyleGenerator()
null
if no generator is
setpublic void editRow(int rowIndex)
rowIndex
- the index of the row to be editedIllegalStateException
- if the editor is not enabledIllegalStateException
- if the editor is already in edit modepublic boolean isEditorActive()
true
if the editor is active, false
otherwise.public void saveEditor()
IllegalStateException
- if the editor is not enabledIllegalStateException
- if the editor is not in edit modepublic void cancelEditor()
saved
are lost.IllegalStateException
- if the editor is not enabledIllegalStateException
- if the editor is not in edit modepublic EditorHandler<T> getEditorHandler()
public void setEditorHandler(EditorHandler<T> handler)
rowHandler
- the new editor handlerIllegalStateException
- if the editor is currently in edit modepublic boolean isEditorEnabled()
public void setEditorEnabled(boolean enabled)
enabled
- true to enable editing, false to disableIllegalStateException
- if in edit mode and trying to disableIllegalStateException
- if the editor handler is not setpublic com.google.gwt.user.client.ui.Widget getEditorWidget(Grid.Column<?,T> column)
column
- the columnpublic void setEditorSaveCaption(String saveCaption) throws IllegalArgumentException
saveCaption
- the caption to setIllegalArgumentException
- if saveCaption
is null
public String getEditorSaveCaption()
public void setEditorCancelCaption(String cancelCaption) throws IllegalArgumentException
cancelCaption
- the caption to setIllegalArgumentException
- if cancelCaption
is null
public String getEditorCancelCaption()
protected void onAttach()
onAttach
in class com.google.gwt.user.client.ui.Composite
protected void onDetach()
onDetach
in class com.google.gwt.user.client.ui.Composite
public void onResize()
onResize
in interface com.google.gwt.user.client.ui.RequiresResize
onResize
in class com.google.gwt.user.client.ui.ResizeComposite
@Deprecated public void add(com.google.gwt.user.client.ui.Widget w)
This method is implemented only because removing widgets from Grid (added
via e.g. Renderer
s) requires the HasWidgets
interface.
add
in interface com.google.gwt.user.client.ui.HasWidgets
w
- irrelevantUnsupportedOperationException
- always@Deprecated public void clear()
This method is implemented only because removing widgets from Grid (added
via e.g. Renderer
s) requires the HasWidgets
interface.
clear
in interface com.google.gwt.user.client.ui.HasWidgets
UnsupportedOperationException
- always@Deprecated public Iterator<com.google.gwt.user.client.ui.Widget> iterator()
This method is implemented only because removing widgets from Grid (added
via e.g. Renderer
s) requires the HasWidgets
interface.
iterator
in interface com.google.gwt.user.client.ui.HasWidgets
iterator
in interface Iterable<com.google.gwt.user.client.ui.Widget>
UnsupportedOperationException
- always@Deprecated public boolean remove(com.google.gwt.user.client.ui.Widget w)
This method is implemented only because removing widgets from Grid (added
via e.g. Renderer
s) requires the HasWidgets
interface.
remove
in interface com.google.gwt.user.client.ui.HasWidgets
false
protected void doAttachChildren()
doAttachChildren
in class com.google.gwt.user.client.ui.Widget
protected void doDetachChildren()
doDetachChildren
in class com.google.gwt.user.client.ui.Widget
public void resetSizesFromDom()
public void setDetailsGenerator(DetailsGenerator detailsGenerator) throws IllegalArgumentException
The currently opened row details will be re-rendered.
detailsGenerator
- the details generator to setIllegalArgumentException
- if detailsGenerator is null
;public DetailsGenerator getDetailsGenerator()
public void setDetailsVisible(int rowIndex, boolean visible)
This method does nothing if trying to set show already-visible details, or hide already-hidden details.
rowIndex
- the index of the affected rowvisible
- true
to show the details, or false
to hide themisDetailsVisible(int)
public boolean isDetailsVisible(int rowIndex)
rowIndex
- the index of the row for which to check detailstrue
iff the details for the given row is visiblesetDetailsVisible(int, boolean)
public void setDetailsHeight(int rowIndex, double height)
rowIndex
- the index of the row for which to update details heightheight
- new height of the details rowpublic void recalculateColumnWidths()
The actual recalculation is not necessarily done immediately so you cannot rely on the columns being the correct width after the call returns.
public com.google.gwt.user.client.ui.MenuBar getSidebarMenu()
public boolean isSidebarOpen()
true
if the sidebar is open; false
if
it is closedgetSidebarMenu()
public void setSidebarOpen(boolean sidebarOpen)
sidebarOpen
- true
to open the sidebar; false
to
close itgetSidebarMenu()
,
isSidebarOpen()
public int getTabIndex()
getTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void setAccessKey(char key)
setAccessKey
in interface com.google.gwt.user.client.ui.Focusable
public void setFocus(boolean focused)
setFocus
in interface com.google.gwt.user.client.ui.Focusable
public void setTabIndex(int index)
setTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void focus()
Focusable
public void setEditorBuffered(boolean editorBuffered)
editorUnbuffered
- true
to enable buffered editor,
false
to disable itpublic boolean isEditorBuffered()
true
if buffered editor is enabled,
false
otherwisepublic EventCellReference<T> getEventCell()
EventCellReference
for the latest event fired from
this Grid.
Note: This cell reference will be updated when firing the next event.
public CellReference<T> getCellReference(com.google.gwt.dom.client.Element element)
element
- Element to find from the cell's content.null
if cell was not found.public boolean isUserSelectionAllowed()
true
if selection by the user is allowed by the
selection model (the default), false
otherwiseCopyright © 2019 Vaadin Ltd. All rights reserved.