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>
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>
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 theGrid 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
-
Field Summary
Fields Modifier and Type Field Description protected com.vaadin.client.widgets.Grid.CellFocusHandler
cellFocusHandler
-
Constructor Summary
Constructors Constructor Description Grid()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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)
com.google.gwt.event.shared.HandlerRegistration
addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
com.google.gwt.event.shared.HandlerRegistration
addScrollHandler(ScrollHandler handler)
Adds a scroll handler to this gridcom.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 cellsGrid.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 theEscalator
used by this Grid instnace.EventCellReference<T>
getEventCell()
Returns theEventCellReference
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, whilegetHeightMode()
isHeightMode.ROW
.HeightMode
getHeightMode()
Returns the currentHeightMode
the Grid is in.RowStyleGenerator<T>
getRowStyleGenerator()
Gets the style generator that is used for generating styles for rowsdouble
getScrollHeight()
Returns the height of the scrollable area in pixels.double
getScrollLeft()
Gets the horizontal scroll offsetdouble
getScrollTop()
Gets the vertical scroll offsetdouble
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 insubPart
.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(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
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, usingScrollDestination.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 cellsvoid
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, whilegetHeightMode()
isHeightMode.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 rowsvoid
setScrollLeft(double px)
Sets the horizontal scroll offsetvoid
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)
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
-
-
-
-
Field Detail
-
cellFocusHandler
protected final com.vaadin.client.widgets.Grid.CellFocusHandler cellFocusHandler
-
-
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 isColumnResizeMode.ANIMATED
.- Parameters:
mode
- a ColumnResizeMode value- Since:
- 7.7.5
-
getColumnResizeMode
public ColumnResizeMode getColumnResizeMode()
Returns the current column resize mode. The default mode isColumnResizeMode.ANIMATED
.- Returns:
- a ColumnResizeMode value
- Since:
- 7.7.5
-
setStylePrimaryName
public void setStylePrimaryName(String style)
- Overrides:
setStylePrimaryName
in classcom.google.gwt.user.client.ui.UIObject
-
createHeaderUpdater
protected EscalatorUpdater createHeaderUpdater()
Creates the escalator updater used to update the header rows in this grid. The updater is invoked when header rows or columns are added or removed, or the content of existing header cells is changed.- Returns:
- the new header updater instance
- See Also:
GridHeader
,getHeader()
-
createBodyUpdater
protected EscalatorUpdater createBodyUpdater()
Creates the escalator updater used to update the body rows in this grid. The updater is invoked when body rows or columns are added or removed, the content of body cells is changed, or the body is scrolled to expose previously hidden content.- Returns:
- the new body updater instance
-
createFooterUpdater
protected EscalatorUpdater createFooterUpdater()
Creates the escalator updater used to update the footer rows in this grid. The updater is invoked when header rows or columns are added or removed, or the content of existing header cells is changed.- Returns:
- the new footer updater instance
- See Also:
GridFooter
,getFooter()
-
addColumns
public void addColumns(Grid.Column<?,T>... columns)
Adds columns as the last columns in the grid.- Parameters:
columns
- the columns to add
-
addColumn
public <C extends Grid.Column<?,T>> C addColumn(C column)
Adds a column as the last column in the grid.- Parameters:
column
- the column to add- Returns:
- given column
-
addColumn
public <C extends Grid.Column<?,T>> C addColumn(C column, int index)
Inserts a column into a specific position in the grid.- Parameters:
index
- the index where the column should be inserted intocolumn
- the column to add- Returns:
- given column
- Throws:
IllegalStateException
- if Grid's current selection model renders a selection column, 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 column- Returns:
- The column in the given index
- Throws:
IllegalArgumentException
- if the column index does not exist in the grid
-
getHeader
protected Grid.Header getHeader()
Returns the header section of this grid. The default header contains a single row displaying the column captions.- Returns:
- the header
-
getHeaderRow
public Grid.HeaderRow getHeaderRow(int rowIndex)
Gets the header row at given index.- Parameters:
rowIndex
- 0 based index for row. Counted from top to bottom- Returns:
- header row at given index
- Throws:
IllegalArgumentException
- if no row exists at given index
-
addHeaderRowAt
public Grid.HeaderRow addHeaderRowAt(int index)
Inserts a new row at the given position to the header section. Shifts the row currently at that position and any subsequent rows down (adds one to their indices).- Parameters:
index
- the position at which to insert the row- Returns:
- the new row
- Throws:
IllegalArgumentException
- if the index is less than 0 or greater than row count- See Also:
appendHeaderRow()
,prependHeaderRow()
,removeHeaderRow(HeaderRow)
,removeHeaderRow(int)
-
appendHeaderRow
public Grid.HeaderRow appendHeaderRow()
Adds a new row at the bottom of the header section.- Returns:
- the new row
- See Also:
prependHeaderRow()
,addHeaderRowAt(int)
,removeHeaderRow(HeaderRow)
,removeHeaderRow(int)
-
getDefaultHeaderRow
public Grid.HeaderRow getDefaultHeaderRow()
Returns the current default row of the header section. The default row is a special header row providing a user interface for sorting columns. Setting a header caption for column updates cells in the default header.- Returns:
- the default row or null if no default row set
-
getHeaderRowCount
public int getHeaderRowCount()
Gets the row count for the header section.- Returns:
- row count
-
prependHeaderRow
public Grid.HeaderRow prependHeaderRow()
Adds a new row at the top of the header section.- Returns:
- the new row
- See Also:
appendHeaderRow()
,addHeaderRowAt(int)
,removeHeaderRow(HeaderRow)
,removeHeaderRow(int)
-
removeHeaderRow
public void removeHeaderRow(Grid.HeaderRow row)
Removes the given row from the header section.- Parameters:
row
- the row to be removed- Throws:
IllegalArgumentException
- if the row does not exist in this section- See Also:
removeHeaderRow(int)
,addHeaderRowAt(int)
,appendHeaderRow()
,prependHeaderRow()
-
removeHeaderRow
public void removeHeaderRow(int rowIndex)
Removes the row at the given position from the header section.- Parameters:
index
- the position of the row- Throws:
IllegalArgumentException
- if no row exists at given index- See Also:
removeHeaderRow(HeaderRow)
,addHeaderRowAt(int)
,appendHeaderRow()
,prependHeaderRow()
-
setDefaultHeaderRow
public void setDefaultHeaderRow(Grid.HeaderRow row)
Sets the default row of the header. The default row is a special header row providing a user interface for sorting columns.Note: Setting the default header row will reset all cell contents to Column defaults.
- Parameters:
row
- the new default row, or null for no default row- Throws:
IllegalArgumentException
- header does not contain the row
-
setHeaderVisible
public void setHeaderVisible(boolean visible)
Sets the visibility of the header section.- Parameters:
visible
- true to show header section, false to hide
-
isHeaderVisible
public boolean isHeaderVisible()
Returns the visibility of the header section.- Returns:
- true if visible, false otherwise.
-
getFooter
protected Grid.Footer getFooter()
Returns the footer section of this grid. The default footer is empty.- Returns:
- the footer
-
getFooterRow
public Grid.FooterRow getFooterRow(int rowIndex)
Gets the footer row at given index.- Parameters:
rowIndex
- 0 based index for row. Counted from top to bottom- Returns:
- footer row at given index
- Throws:
IllegalArgumentException
- if no row exists at given index
-
addFooterRowAt
public Grid.FooterRow addFooterRowAt(int index)
Inserts a new row at the given position to the footer section. Shifts the row currently at that position and any subsequent rows down (adds one to their indices).- Parameters:
index
- the position at which to insert the row- Returns:
- the new row
- Throws:
IllegalArgumentException
- if the index is less than 0 or greater than row count- See Also:
appendFooterRow()
,prependFooterRow()
,removeFooterRow(FooterRow)
,removeFooterRow(int)
-
appendFooterRow
public Grid.FooterRow appendFooterRow()
Adds a new row at the bottom of the footer section.- Returns:
- the new row
- See Also:
prependFooterRow()
,addFooterRowAt(int)
,removeFooterRow(FooterRow)
,removeFooterRow(int)
-
getFooterRowCount
public int getFooterRowCount()
Gets the row count for the footer.- Returns:
- row count
-
prependFooterRow
public Grid.FooterRow prependFooterRow()
Adds a new row at the top of the footer section.- Returns:
- the new row
- See Also:
appendFooterRow()
,addFooterRowAt(int)
,removeFooterRow(FooterRow)
,removeFooterRow(int)
-
removeFooterRow
public void removeFooterRow(Grid.FooterRow row)
Removes the given row from the footer section.- Parameters:
row
- the row to be removed- Throws:
IllegalArgumentException
- if the row does not exist in this section- See Also:
removeFooterRow(int)
,addFooterRowAt(int)
,appendFooterRow()
,prependFooterRow()
-
removeFooterRow
public void removeFooterRow(int rowIndex)
Removes the row at the given position from the footer section.- Parameters:
index
- the position of the row- Throws:
IllegalArgumentException
- if no row exists at given index- See Also:
removeFooterRow(FooterRow)
,addFooterRowAt(int)
,appendFooterRow()
,prependFooterRow()
-
setFooterVisible
public void setFooterVisible(boolean visible)
Sets the visibility of the footer section.- Parameters:
visible
- true to show footer section, false to hide
-
isFooterVisible
public boolean isFooterVisible()
Returns the visibility of the footer section.- Returns:
- true if visible, false otherwise.
-
getEditor
public Grid.Editor<T> getEditor()
-
getEscalator
public Escalator getEscalator()
Gets theEscalator
used by this Grid instnace.- 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:
setHeightMode(HeightMode)
-
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 null- Throws:
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 frozen- Throws:
IllegalArgumentException
- if the column count is < -1 or > the number of visible columns
-
getFrozenColumnCount
public int getFrozenColumnCount()
Gets the number of frozen columns in this grid. 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. -1 means that not even the selection column is frozen.NOTE: This includes
hidden columns
in the count.- Returns:
- the number of frozen columns
-
addRowVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addRowVisibilityChangeHandler(RowVisibilityChangeHandler handler)
-
scrollToRow
public void scrollToRow(int rowIndex) throws IllegalArgumentException
Scrolls to a certain row, usingScrollDestination.ANY
.If the details for that row are visible, those will be taken into account as well.
- Parameters:
rowIndex
- zero-based index of the row to scroll to.- Throws:
IllegalArgumentException
- if rowIndex is below zero, or above the maximum value supported by the data source.
-
scrollToRow
public void scrollToRow(int rowIndex, ScrollDestination destination) throws 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.
-
scrollToStart
public void scrollToStart()
Scrolls to the beginning of the very first row.
-
scrollToEnd
public void scrollToEnd()
Scrolls to the end of the very last row.
-
setScrollTop
public void setScrollTop(double px)
Sets the vertical scroll offset.- Parameters:
px
- the number of pixels this grid should be scrolled down
-
getScrollTop
public double getScrollTop()
Gets the vertical scroll offset- Returns:
- the number of pixels this grid is scrolled down
-
setScrollLeft
public void setScrollLeft(double px)
Sets the horizontal scroll offset- Parameters:
px
- the number of pixels this grid should be scrolled right- Since:
- 7.5.0
-
getScrollLeft
public double getScrollLeft()
Gets the horizontal scroll offset- Returns:
- the number of pixels this grid is scrolled to the right
-
getScrollHeight
public double getScrollHeight()
Returns the height of the scrollable area in pixels.- Returns:
- the height of the scrollable area in pixels
- Since:
- 7.5.0
-
getScrollWidth
public double getScrollWidth()
Returns the width of the scrollable area in pixels.- Returns:
- the width of the scrollable area in pixels.
- Since:
- 7.5.0
-
setHeightByRows
public void setHeightByRows(double rows) throws IllegalArgumentException
Sets the number of rows that should be visible in Grid's body, whilegetHeightMode()
isHeightMode.ROW
.If Grid is currently not in
HeightMode.ROW
, the given value is remembered, and applied once the mode is applied.- Parameters:
rows
- The height in terms of number of rows displayed in Grid's body. If Grid doesn't contain enough rows, white space is displayed instead.- Throws:
IllegalArgumentException
- ifrows
is zero or lessIllegalArgumentException
- ifrows
isinfinite
IllegalArgumentException
- ifrows
isNaN
- See Also:
setHeightMode(HeightMode)
-
getHeightByRows
public double getHeightByRows()
Gets the amount of rows in Grid's body that are shown, whilegetHeightMode()
isHeightMode.ROW
.By default, it is .
- Returns:
- the amount of rows that should be shown in Grid's body, while in
HeightMode.ROW
. - See Also:
setHeightByRows(double)
-
setHeightMode
public void setHeightMode(HeightMode heightMode)
Defines the mode in which the Grid widget's height is calculated.If
HeightMode.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 currentHeightMode
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 insubPart
. 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 component- Returns:
- 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. ThesubElement
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 identify- Returns:
- 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.This function will call
SelectionModel.setGrid(Grid)
.- Parameters:
selectionModel
- a selection model implementation.- Throws:
IllegalArgumentException
- if selection model argument is null
-
getSelectionModel
public SelectionModel<T> getSelectionModel()
Gets a reference to the current selection model.- Returns:
- the currently used SelectionModel instance.
-
setSelectionMode
public void setSelectionMode(Grid.SelectionMode mode)
Sets current selection mode.This is a shorthand method for
setSelectionModel(com.vaadin.client.widget.grid.selection.SelectionModel<T>)
.- Parameters:
mode
- a selection mode value- See Also:
Grid.SelectionMode
-
isSelected
public boolean isSelected(T row)
Test if a row is selected.- Parameters:
row
- a row object- Returns:
- true, if the current selection model considers the provided row object selected.
-
select
public boolean select(T row)
Select a row using the current selection model.Only selection models implementing
SelectionModel.Single
andSelectionModel.Multi
are supported; for anything else, an exception will be thrown.- Parameters:
row
- a row object- Returns:
true
iff the current selection changed- Throws:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
deselect
public boolean deselect(T row)
Deselect 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 object- Returns:
true
iff the current selection changed- Throws:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
deselectAll
public boolean deselectAll()
Deselect all rows using the current selection model.- Returns:
true
iff the current selection changed- Throws:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
orSelectionModel.Multi
-
getSelectedRow
public T getSelectedRow()
Gets last selected row from the current SelectionModel.Only selection models implementing
SelectionModel.Single
are valid for this method; for anything else, use thegetSelectedRows()
method.- Returns:
- a selected row reference, or null, if no row is selected
- Throws:
IllegalStateException
- if the current selection model is not an instance ofSelectionModel.Single
-
getSelectedRows
public Collection<T> getSelectedRows()
Gets currently selected rows from the current selection model.- Returns:
- a non-null collection containing all currently selected rows.
-
addSelectionHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(SelectionHandler<T> handler)
Description copied from interface: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 forSort
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.- Parameters:
column
- a grid column reference
-
sort
public <C> void sort(Grid.Column<C,T> column, SortDirection direction)
Sorts the Grid data along one column.- Parameters:
column
- a grid column referencedirection
- a sort direction value
-
setSortOrder
public void setSortOrder(List<SortOrder> order)
Sets the sort order to use. Setting this causes the Grid to re-sort itself.- Parameters:
order
- a sort order list. If set to null, the sort order is cleared.
-
getSortOrder
public List<SortOrder> getSortOrder()
Get a copy of the current sort order array.- Returns:
- a copy of the current sort order array
-
addSortHandler
public com.google.gwt.event.shared.HandlerRegistration addSortHandler(SortHandler<T> handler)
Register a GWT event handler for a sorting event. This handler gets called whenever this Grid needs its data source to provide data sorted in a specific order.- Parameters:
handler
- a sort event handler- Returns:
- the registration for the event
-
addSelectAllHandler
public com.google.gwt.event.shared.HandlerRegistration addSelectAllHandler(SelectAllHandler<T> handler)
Register a GWT event handler for a select all event. This handler gets called whenever Grid needs all rows selected.- Parameters:
handler
- a select all event handler
-
addDataAvailableHandler
public com.google.gwt.event.shared.HandlerRegistration addDataAvailableHandler(DataAvailableHandler handler)
Register a GWT event handler for a data available event. This handler gets called whenever theDataSource
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 handler- Returns:
- the registartion for the event
-
addBodyKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyDownHandler(BodyKeyDownHandler handler)
Register a BodyKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Body of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addBodyKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyUpHandler(BodyKeyUpHandler handler)
Register a BodyKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Body of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addBodyKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyKeyPressHandler(BodyKeyPressHandler handler)
Register a BodyKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Body of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyDownHandler(HeaderKeyDownHandler handler)
Register a HeaderKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Header of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyUpHandler(HeaderKeyUpHandler handler)
Register a HeaderKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Header of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addHeaderKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderKeyPressHandler(HeaderKeyPressHandler handler)
Register a HeaderKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Header of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyDownHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyDownHandler(FooterKeyDownHandler handler)
Register a FooterKeyDownHandler to this Grid. The event for this handler is fired when a KeyDown event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyUpHandler(FooterKeyUpHandler handler)
Register a FooterKeyUpHandler to this Grid. The event for this handler is fired when a KeyUp event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addFooterKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterKeyPressHandler(FooterKeyPressHandler handler)
Register a FooterKeyPressHandler to this Grid. The event for this handler is fired when a KeyPress event occurs while cell focus is in the Footer of this Grid.- Parameters:
handler
- the key handler to register- Returns:
- the registration for the event
-
addBodyClickHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyClickHandler(BodyClickHandler handler)
Register a BodyClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Body of this Grid.- Parameters:
handler
- the click handler to register- Returns:
- the registration for the event
-
addHeaderClickHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderClickHandler(HeaderClickHandler handler)
Register a HeaderClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Header of this Grid.- Parameters:
handler
- the click handler to register- Returns:
- the registration for the event
-
addFooterClickHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterClickHandler(FooterClickHandler handler)
Register a FooterClickHandler to this Grid. The event for this handler is fired when a Click event occurs in the Footer of this Grid.- Parameters:
handler
- the click handler to register- Returns:
- the registration for the event
-
addBodyDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addBodyDoubleClickHandler(BodyDoubleClickHandler handler)
Register a BodyDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Body of this Grid.- Parameters:
handler
- the double click handler to register- Returns:
- the registration for the event
-
addHeaderDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addHeaderDoubleClickHandler(HeaderDoubleClickHandler handler)
Register a HeaderDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Header of this Grid.- Parameters:
handler
- the double click handler to register- Returns:
- the registration for the event
-
addFooterDoubleClickHandler
public com.google.gwt.event.shared.HandlerRegistration addFooterDoubleClickHandler(FooterDoubleClickHandler handler)
Register a FooterDoubleClickHandler to this Grid. The event for this handler is fired when a double click event occurs in the Footer of this Grid.- Parameters:
handler
- the double click handler to register- Returns:
- the registration for the event
-
addColumnReorderHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnReorderHandler(ColumnReorderHandler<T> handler)
Register a column reorder handler to this Grid. The event for this handler is fired when the Grid's columns are reordered.- Parameters:
handler
- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.5.0
-
addColumnVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnVisibilityChangeHandler(ColumnVisibilityChangeHandler<T> handler)
Register a column visibility change handler to this Grid. The event for this handler is fired when the Grid's columns change visibility.- Parameters:
handler
- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.5.0
-
addColumnResizeHandler
public com.google.gwt.event.shared.HandlerRegistration addColumnResizeHandler(ColumnResizeHandler<T> handler)
Register a column resize handler to this Grid. The event for this handler is fired when the Grid's columns are resized.- Parameters:
handler
- the handler for the event- Returns:
- the registration for the event
- Since:
- 7.6
-
addEnabledHandler
public com.google.gwt.event.shared.HandlerRegistration addEnabledHandler(GridEnabledHandler handler)
Register a enabled status change handler to this Grid. The event for this handler is fired when the Grid changes from disabled to enabled and vice-versa.- Parameters:
handler
- the handler for the event- Returns:
- the registration for the event
-
addRowHeightChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addRowHeightChangedHandler(RowHeightChangedHandler handler)
-
addSpacerVisibilityChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addSpacerVisibilityChangedHandler(SpacerVisibilityChangedHandler handler)
Adds a spacer visibility changed handler to the underlying escalator.- Parameters:
handler
- the handler to be called when a spacer's visibility changes- Returns:
- the registration object with which the handler can be removed
- Since:
- 7.7.13
-
addBrowserEventHandler
public void addBrowserEventHandler(int index, GridEventHandler<T> handler)
Adds a low-level DOM event handler to this Grid. The handler is inserted into the given position in the list of handlers. The handlers are invoked in order. If theonEvent
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 add- Returns:
- 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 otherwise- Since:
- 7.5.0
-
setColumnReorderingAllowed
public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether column reordering with drag and drop is allowed or not.- Parameters:
columnReorderingAllowed
- specifies whether column reordering is allowed- Since:
- 7.5.0
-
setColumnOrder
public void setColumnOrder(Grid.Column<?,T>... orderedColumns)
Sets a new column order for the grid. All columns which are not ordered here will remain in the order they were before as the last columns of grid.- Parameters:
orderedColumns
- array of columns in wanted order
-
setCellStyleGenerator
public void setCellStyleGenerator(CellStyleGenerator<T> cellStyleGenerator)
Sets the style generator that is used for generating styles for cells- Parameters:
cellStyleGenerator
- the cell style generator to set, 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 edited- Throws:
IllegalStateException
- if the editor is not enabledIllegalStateException
- if the editor is already in edit mode
-
isEditorActive
public boolean isEditorActive()
Returns whether the editor is currently open on some row.- Returns:
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 notsaved
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:
rowHandler
- the new editor handler- Throws:
IllegalStateException
- if the editor is currently in edit mode
-
isEditorEnabled
public boolean isEditorEnabled()
Returns the enabled state of the editor.- Returns:
- true if editing is enabled, false otherwise
-
setEditorEnabled
public void setEditorEnabled(boolean enabled)
Sets the enabled state of the editor.- Parameters:
enabled
- true to enable editing, false to disable- Throws:
IllegalStateException
- if in edit mode and trying to disableIllegalStateException
- if the editor handler is not set
-
getEditorWidget
public com.google.gwt.user.client.ui.Widget getEditorWidget(Grid.Column<?,T> column)
Returns the editor widget associated with the given column. If the editor is not active, returns null.- Parameters:
column
- the column- Returns:
- the widget if the editor is open, null otherwise
-
setEditorSaveCaption
public void setEditorSaveCaption(String saveCaption) throws IllegalArgumentException
Sets the caption on the save button in the Grid editor.- Parameters:
saveCaption
- the caption to set- Throws:
IllegalArgumentException
- 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 set- Throws:
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
- irrelevant- Throws:
UnsupportedOperationException
- always
-
clear
@Deprecated public void clear()
Deprecated.Grid does not support clearing Widgets this way.This method is implemented only because removing widgets from Grid (added via e.g.
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 set- Throws:
IllegalArgumentException
- if detailsGenerator isnull
;- Since:
- 7.5.0
-
getDetailsGenerator
public DetailsGenerator getDetailsGenerator()
Gets the current details generator for row details.- Returns:
- the detailsGenerator the current details generator
- Since:
- 7.5.0
-
setDetailsVisible
public void setDetailsVisible(int rowIndex, boolean visible)
Shows or hides the details for a specific row.This method does nothing if trying to set show already-visible details, or hide already-hidden details.
- Parameters:
rowIndex
- the index of the affected rowvisible
-true
to show the details, orfalse
to hide them- Since:
- 7.5.0
- See Also:
isDetailsVisible(int)
-
isDetailsVisible
public boolean isDetailsVisible(int rowIndex)
Check whether the details for a row is visible or not.- Parameters:
rowIndex
- the index of the row for which to check details- Returns:
true
iff the details for the given row is visible- Since:
- 7.5.0
- See Also:
setDetailsVisible(int, boolean)
-
setDetailsHeight
public void setDetailsHeight(int rowIndex, double height)
Update details row height.- Parameters:
rowIndex
- the index of the row for which to update details heightheight
- new height of the details row- Since:
- 7.7.11
-
recalculateColumnWidths
public void recalculateColumnWidths()
Requests that the column widths should be recalculated.The actual recalculation is not necessarily done immediately so you cannot rely on the columns being the correct width after the call returns.
- Since:
- 7.4.1
-
getSidebarMenu
public com.google.gwt.user.client.ui.MenuBar getSidebarMenu()
Gets the customizable menu bar that is by default used for toggling column hidability. The application developer is allowed to add their custom items to the end of the menu, but should try to avoid modifying the items in the beginning of the menu that control the column hiding if any columns are marked as hidable. A toggle for opening the menu will be displayed whenever the menu contains at least one item.- Returns:
- the menu bar
- Since:
- 7.5.0
-
isSidebarOpen
public boolean isSidebarOpen()
Tests whether the sidebar menu is currently open.- Returns:
true
if the sidebar is open;false
if it is closed- Since:
- 7.5.0
- See Also:
getSidebarMenu()
-
setSidebarOpen
public void setSidebarOpen(boolean sidebarOpen)
Sets whether the sidebar menu is open.- Parameters:
sidebarOpen
-true
to open the sidebar;false
to close it- Since:
- 7.5.0
- See Also:
getSidebarMenu()
,isSidebarOpen()
-
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:
editorUnbuffered
-true
to enable buffered editor,false
to disable it- Since:
- 7.6
-
isEditorBuffered
public boolean isEditorBuffered()
Gets the buffered editor mode.- Returns:
true
if buffered editor is enabled,false
otherwise- Since:
- 7.6
-
getEventCell
public EventCellReference<T> getEventCell()
Returns theEventCellReference
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
-
isUserSelectionAllowed
public boolean isUserSelectionAllowed()
Checks if selection by the user is allowed in the grid.- Returns:
true
if selection by the user is allowed by the selection model (the default),false
otherwise- Since:
- 7.7.7
-
-