com.vaadin.client.widgets.
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.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>
Direct Known Subclasses:
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
. EachGridColumn
has 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
GridColumn
and display it to the user. A simple column might have aTextRenderer
that simply takes in aString
and displays it as the cell's content. A more complex renderer might beProgressBarRenderer
that 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 class
Grid.AbstractGridKeyEvent<HANDLER extends AbstractGridKeyEventHandler>
Event class for key events that happen within the grid.
static class
Grid.AbstractGridMouseEvent<HANDLER extends AbstractGridMouseEventHandler>
Event class for mouse events that happen within the grid.
protected class
Grid.BodyUpdater
EscalatorUpdater implementation for Grid's body section.
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 class
Grid.FocusStack
Helper class for storing and restoring previously stored focus.
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
A column that contains CheckBoxes for representing Grid's row selection.
static class
Grid.StaticSection<ROWTYPE extends Grid.StaticSection.StaticRow<?>>
Abstract base class for Grid header and footer sections.
protected class
Grid.StaticSectionUpdater
EscalatorUpdater implementation for Grid's static sections (header and footer).
-
Field Summary
Fields Modifier and Type Field Description protected com.vaadin.client.widgets.Grid.CellFocusHandler
cellFocusHandler
Focus handler for Grid's cells.
-
Constructor Summary
Constructors Constructor Description Grid()
Creates a new instance.
-
Method Summary
All Methods Modifier and Type Method 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>>
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.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)
Register a row height changed handler to this Grid.
com.google.gwt.event.shared.HandlerRegistration
addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
Adds an event handler that gets notified when the range of visible rows changes e.g.
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
addSelectionAllowedHandler(GridSelectionAllowedHandler handler)
Register a selection allowed status change handler to this Grid.
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
addSpacerIndexChangedHandler(SpacerIndexChangedHandler handler)
Adds a spacer index changed handler to the underlying escalator.
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.
void
deselect(T row)
Deselects a row using the current selection model.
void
deselectAll()
Deselects 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()
Returns the
Grid.Editor
for this Grid.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 instance.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()
isHeightMode.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.
Optional<Grid.SelectionColumn>
getSelectionColumn()
Returns the selection column for the grid if the selection model is of type
SelectionModelWithSelectionColumn
.SelectionModel<T>
getSelectionModel()
Gets a reference to the current selection model.
GridConstants.SidebarColumnOrder
getSidebarColumnOrder()
Get the set ordering of the columns in the sidebar menu
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
isReadOnly()
Gets the Grid's read-only state.
boolean
isSelected(T row)
Returns if a row is selected.
boolean
isSidebarOpen()
Tests whether the sidebar menu is currently open.
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(int rowIndex)
Removes the row at the given position from the footer section.
void
removeFooterRow(Grid.FooterRow row)
Removes the given row from the footer section.
void
removeHeaderRow(int rowIndex)
Removes the row at the given position from the header section.
void
removeHeaderRow(Grid.HeaderRow row)
Removes the given row from the header section.
void
requestRefreshBody()
Request delayed refresh of all body rows.
void
resetSizesFromDom()
Resets all cached pixel sizes and reads new values from the DOM.
void
resetVisibleDetails(int rowIndex)
Reset the details row with current contents.
void
saveEditor()
Saves any unsaved changes in the editor to the data source.
void
scrollToColumn(int columnIndexDOM, ScrollDestination destination)
Scrolls to a certain column, using user-specified scroll destination.
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
scrollToRow(int rowIndex, ScrollDestination destination, Runnable callback)
Helper method for making sure desired row is visible and it is properly rendered.
void
scrollToRow(int rowIndex, Runnable whenRendered)
Helper method for making sure desired row is visible and it is properly rendered.
void
scrollToStart()
Scrolls to the beginning of the very first row.
void
select(T row)
Selects a row using the current selection model.
void
setAccessKey(char key)
protected void
setAriaRole(String role)
Adds the given role as 'role="$param"' to the
<table>
element of the grid.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()
isHeightMode.ROW
.void
setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.
void
setReadOnly(boolean readOnly)
Sets the Grid's read-only state.
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
setSelectionModel(SelectionModel<T> selectionModel)
Sets the current selection model.
void
setSidebarColumnOrder(GridConstants.SidebarColumnOrder order)
Set the order of the columns in the sidebar menu.
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)
void
sort(Sort s)
Sets the current sort order using the fluid Sort API.
<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.
-
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:
isEnabled
in interfacecom.google.gwt.user.client.ui.HasEnabled
-
setEnabled
public void setEnabled(boolean enabled)
Specified by:
setEnabled
in interfacecom.google.gwt.user.client.ui.HasEnabled
-
setColumnResizeMode
public void setColumnResizeMode(ColumnResizeMode mode)
Sets the column resize mode to use. The default mode is
ColumnResizeMode.ANIMATED
.Parameters:
mode
- a ColumnResizeMode valueSince:
7.7.5
-
getColumnResizeMode
public ColumnResizeMode getColumnResizeMode()
Returns the current column resize mode. The default mode is
ColumnResizeMode.ANIMATED
.Returns:
a ColumnResizeMode value
Since:
7.7.5
-
setStylePrimaryName
public void setStylePrimaryName(String style)
Overrides:
setStylePrimaryName
in classcom.google.gwt.user.client.ui.UIObject
-
setAriaRole
protected void setAriaRole(String role)
Adds the given role as 'role="$param"' to the
<table>
element of the grid.Parameters:
role
- the role paramSince:
8.2
-
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()
-
requestRefreshBody
public void requestRefreshBody()
Request delayed refresh of all body rows.
Since:
8.1
-
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.
Type Parameters:
C
- class that extends ColumnParameters:
column
- the column to addReturns:
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.
Type Parameters:
C
- class that extends ColumnParameters:
column
- the column to addindex
- the index where the column should be inserted intoReturns:
given column
Throws:
IllegalStateException
- if Grid's current selection model renders a selection column, andindex
is 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
hidden
columns 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 columnReturns:
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 bottomReturns:
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 rowReturns:
the new row
Throws:
IllegalArgumentException
- if the index is less than 0 or greater than row countSee 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 removedThrows:
IllegalArgumentException
- if the row does not exist in this sectionSee 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 position of the rowThrows:
IllegalArgumentException
- if no row exists at given indexSee 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 rowThrows:
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 bottomReturns:
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 rowReturns:
the new row
Throws:
IllegalArgumentException
- if the index is less than 0 or greater than row countSee 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 removedThrows:
IllegalArgumentException
- if the row does not exist in this sectionSee 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 rowThrows:
IllegalArgumentException
- if no row exists at given indexSee 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()
Returns the
Grid.Editor
for this Grid.Returns:
editor
-
getEscalator
public Escalator getEscalator()
Gets the
Escalator
used 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:
setHeight
in classcom.google.gwt.user.client.ui.UIObject
See Also:
-
setWidth
public void setWidth(String width)
Overrides:
setWidth
in 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 nullThrows:
IllegalArgumentException
- ifdataSource
isnull
-
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 frozenThrows:
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 columns
in the count.Returns:
the number of frozen columns
-
addRowVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
Adds an event handler that gets notified when the range of visible rows changes e.g. because of scrolling, row resizing or spacers appearing/disappearing.
Parameters:
handler
- the event handlerReturns:
a handler registration for the added handler
-
scrollToRow
public void scrollToRow(int rowIndex) throws IllegalArgumentException
Scrolls to a certain row, using
ScrollDestination.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 IllegalArgumentException
Scrolls 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. SeeScrollDestination
for more information.Throws:
IllegalArgumentException
- if rowIndex is below zero, or above the maximum value supported by the data source.
-
scrollToColumn
public void scrollToColumn(int columnIndexDOM, ScrollDestination destination) throws IllegalArgumentException
Scrolls to a certain column, using user-specified scroll destination.
Parameters:
columnIndexDOM
- zero-based index of the visible column to scroll to.destination
- desired destination placement of scrolled-to-column. SeeScrollDestination
for more information.Throws:
IllegalArgumentException
- if columnIndexDOM is below zero or above the maximum value of configured columns, or the column has been configured to be frozenSince:
8.18
-
scrollToRow
public void scrollToRow(int rowIndex, ScrollDestination destination, Runnable callback)
Helper method for making sure desired row is visible and it is properly rendered.
Parameters:
rowIndex
- the row to look fordestination
- the desired scroll destinationcallback
- the callback command to execute when row is availableSince:
8.4
-
scrollToRow
public void scrollToRow(int rowIndex, Runnable whenRendered)
Helper method for making sure desired row is visible and it is properly rendered.
Parameters:
rowIndex
- the row to look forwhenRendered
- the callback command to execute when row is availableSince:
8.4
-
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 rightSince:
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 IllegalArgumentException
Sets the number of rows that should be visible in Grid's body, while
getHeightMode()
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
- ifrows
is zero or lessIllegalArgumentException
- ifrows
isinfinite
IllegalArgumentException
- ifrows
isNaN
See Also:
-
getHeightByRows
public double getHeightByRows()
Gets the amount of rows in Grid's body that are shown, while
getHeightMode()
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:
-
setHeightMode
public void setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.
If
HeightMode.CSS
is given, Grid will respect the values given viasetHeight(String)
, and behave as a traditional Widget.If
HeightMode.ROW
is 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 current
HeightMode
the Grid is in.Defaults to
HeightMode.CSS
.Returns:
the current HeightMode
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent
in classcom.google.gwt.user.client.ui.Composite
-
getSubPartElement
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
Description copied from interface:
SubPartAware
Locates an element inside a component using the identifier provided in
subPart
. ThesubPart
identifier is component specific and may be any string of characters, numbers, space characters and brackets.Specified by:
getSubPartElement
in interfaceSubPartAware
Parameters:
subPart
- The identifier for the element inside the componentReturns:
The element identified by subPart or null if the element could not be found.
-
getSubPartName
public String getSubPartName(com.google.gwt.user.client.Element subElement)
Description copied from interface:
SubPartAware
Provides an identifier that identifies the element within the component. The
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 withsubElement
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 assubElement
because interactions with the DIV and the root button element produce the same result.Specified by:
getSubPartName
in interfaceSubPartAware
Parameters:
subElement
- The element the identifier string should uniquely identifyReturns:
An identifier that uniquely identifies
subElement
or null if no identifier could be provided.
-
setSelectionModel
public void setSelectionModel(SelectionModel<T> selectionModel)
Sets the current selection model.
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.
-
isSelected
public boolean isSelected(T row)
Returns if a row is selected.
Parameters:
row
- a row objectReturns:
true
, if the current selection model considers the provided row object selected.
-
select
public void select(T row)
Selects a row using the current selection model.
Only selection models implementing
SelectionModel.Single
andSelectionModel.Multi
are supported; for anything else, an exception will be thrown.Parameters:
row
- a row objectThrows:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
deselect
public void deselect(T row)
Deselects a row using the current selection model.
Only selection models implementing
SelectionModel.Single
andSelectionModel.Multi
are supported; for anything else, an exception will be thrown.Parameters:
row
- a row objectThrows:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
deselectAll
public void deselectAll()
Deselects all rows using the current selection model.
Throws:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
addSelectionHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(SelectionHandler<T> handler)
Description copied from interface:
HasSelectionHandlers
Register a selection change handler.
This handler is called whenever a
SelectionModel
detects a change in selection state.Specified by:
addSelectionHandler
in 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 for
Sort
for 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.
Type Parameters:
C
- the column typeParameters:
column
- a grid column reference
-
sort
public <C> void sort(Grid.Column<C,T> column, SortDirection direction)
Sorts the Grid data along one column.
Type Parameters:
C
- the column typeParameters:
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 handlerReturns:
the registration for the handler
-
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.
In case the select all checkbox is not visible in the
Grid.SelectionColumn
, it will be come visible after adding the handler.Parameters:
handler
- a select all event handlerReturns:
the registration for the 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 the
DataSource
for 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 handlerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 registerReturns:
the registration for the handler
-
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 eventReturns:
the registration for the handler
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 eventReturns:
the registration for the handler
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 eventReturns:
the registration for the handler
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 eventReturns:
the registration for the handler
-
addSelectionAllowedHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectionAllowedHandler(GridSelectionAllowedHandler handler)
Register a selection allowed status change handler to this Grid. The event for this handler is fired when the Grid changes selection allowed state.
Parameters:
handler
- the handler for the eventReturns:
the registration for the handler
-
addRowHeightChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addRowHeightChangedHandler(RowHeightChangedHandler handler)
Register a row height changed handler to this Grid. The event for this handler is fired when the row height is changed in the Grid's header, body or footer.
Parameters:
handler
- the handler for the eventReturns:
the registration for the 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 changesReturns:
the registration object with which the handler can be removed
Since:
8.3.2
-
addSpacerIndexChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addSpacerIndexChangedHandler(SpacerIndexChangedHandler handler)
Adds a spacer index changed handler to the underlying escalator.
Parameters:
handler
- the handler to be called when a spacer's index changesReturns:
the registration object with which the handler can be removed
Since:
8.9
-
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 the
onEvent
method 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 addReturns:
a handler registration for the registered scroll handler
-
isWorkPending
public boolean isWorkPending()
Description copied from interface:
DeferredWorker
Checks whether there are operations pending for this widget or connector that must be executed before reaching a steady state.
Specified by:
isWorkPending
in interfaceDeferredWorker
-
isColumnReorderingAllowed
public boolean isColumnReorderingAllowed()
Returns whether columns can be reordered with drag and drop.
Returns:
true
if columns can be reordered, false otherwiseSince:
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 allowedSince:
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, ornull
to 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
null
if 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, ornull
to 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
null
if 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 editedThrows:
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:
true
if the editor is active,false
otherwise.
-
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 not
saved
are 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 handlerThrows:
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 disableThrows:
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 columnReturns:
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 setThrows:
IllegalArgumentException
- ifsaveCaption
isnull
-
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 setThrows:
IllegalArgumentException
- ifcancelCaption
isnull
-
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:
onAttach
in classcom.google.gwt.user.client.ui.Composite
-
onDetach
protected void onDetach()
Overrides:
onDetach
in classcom.google.gwt.user.client.ui.Composite
-
onResize
public void onResize()
Specified by:
onResize
in interfacecom.google.gwt.user.client.ui.RequiresResize
Overrides:
onResize
in 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.
Renderer
s) requires theHasWidgets
interface.Specified by:
add
in interfacecom.google.gwt.user.client.ui.HasWidgets
Parameters:
w
- irrelevantThrows:
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.
Renderer
s) requires theHasWidgets
interface.Specified by:
clear
in 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.
Renderer
s) requires theHasWidgets
interface.Specified by:
iterator
in interfacecom.google.gwt.user.client.ui.HasWidgets
Specified by:
iterator
in 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.
Renderer
s) requires theHasWidgets
interface.Specified by:
remove
in interfacecom.google.gwt.user.client.ui.HasWidgets
Returns:
always
false
-
doAttachChildren
protected void doAttachChildren()
Overrides:
doAttachChildren
in classcom.google.gwt.user.client.ui.Widget
-
doDetachChildren
protected void doDetachChildren()
Overrides:
doDetachChildren
in 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 setThrows:
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
-true
to show the details, orfalse
to hide themSince:
7.5.0
See Also:
-
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 detailsReturns:
true
if the details for the given row is visibleSince:
7.5.0
See Also:
-
resetVisibleDetails
public void resetVisibleDetails(int rowIndex)
Reset the details row with current contents.
Parameters:
rowIndex
- the index of the row for which details should be resetSince:
8.13
-
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 rowSince:
8.1.3
-
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
-
getSidebarColumnOrder
public GridConstants.SidebarColumnOrder getSidebarColumnOrder()
Get the set ordering of the columns in the sidebar menu
Returns:
a
GridConstants.SidebarColumnOrder
valueSince:
8.25
-
setSidebarColumnOrder
public void setSidebarColumnOrder(GridConstants.SidebarColumnOrder order)
Set the order of the columns in the sidebar menu.
Since:
8.25
See Also:
-
isSidebarOpen
public boolean isSidebarOpen()
Tests whether the sidebar menu is currently open.
Returns:
true
if the sidebar is open;false
if it is closedSince:
7.5.0
See Also:
-
setSidebarOpen
public void setSidebarOpen(boolean sidebarOpen)
Sets whether the sidebar menu is open.
Parameters:
sidebarOpen
-true
to open the sidebar;false
to close itSince:
7.5.0
See Also:
-
getTabIndex
public int getTabIndex()
Specified by:
getTabIndex
in interfacecom.google.gwt.user.client.ui.Focusable
-
setAccessKey
public void setAccessKey(char key)
Specified by:
setAccessKey
in interfacecom.google.gwt.user.client.ui.Focusable
-
setFocus
public void setFocus(boolean focused)
Specified by:
setFocus
in interfacecom.google.gwt.user.client.ui.Focusable
-
setTabIndex
public void setTabIndex(int index)
Specified by:
setTabIndex
in interfacecom.google.gwt.user.client.ui.Focusable
-
focus
public void focus()
Description copied from interface:
Focusable
Sets focus to this widget.
-
setEditorBuffered
public void setEditorBuffered(boolean editorBuffered)
Sets the buffered editor mode.
Parameters:
editorBuffered
-true
to enable buffered editor,false
to disable itSince:
7.6
-
isEditorBuffered
public boolean isEditorBuffered()
Gets the buffered editor mode.
Returns:
true
if buffered editor is enabled,false
otherwiseSince:
7.6
-
setReadOnly
public void setReadOnly(boolean readOnly)
Sets the Grid's read-only state. Setting the Grid read-only also disables the Editor.
Parameters:
readOnly
-true
if Grid should be set to read-only mode,false
otherwiseSince:
8.22
-
isReadOnly
public boolean isReadOnly()
Gets the Grid's read-only state.
Returns:
true
if Grid is in read-only mode,false
otherwiseSince:
8.22
-
getEventCell
public EventCellReference<T> getEventCell()
Returns the
EventCellReference
for 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
null
if cell was not found.Since:
7.6
-
getSelectionColumn
public Optional<Grid.SelectionColumn> getSelectionColumn()
Returns the selection column for the grid if the selection model is of type
SelectionModelWithSelectionColumn
.Returns:
the select all checkbox, or an empty optional if not in use
-
-