Class 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. Each GridColumn has a custom implementation for Grid.Column.getValue(Object) that gets the row object as an argument, and returns the value for that particular column, extracted from the row object.

    Each column also has a Renderer. Its function is to take the value that is given by the GridColumn and display it to the user. A simple column might have a TextRenderer that simply takes in a String and displays it as the cell's content. A more complex renderer might be ProgressBarRenderer that takes in a floating point number, and displays a progress bar instead, based on the given number.

    See: addColumn(Column), addColumn(Column, int) and addColumns(Column...). Also Grid.Column.setRenderer(Renderer).

    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 (see AbstractRemoteDataSource).

    Since:
    7.4
    Author:
    Vaadin Ltd
    • Constructor Detail

      • Grid

        public Grid()
        Creates a new instance.
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface com.google.gwt.user.client.ui.HasEnabled
      • setEnabled

        public void setEnabled​(boolean enabled)
        Specified by:
        setEnabled in interface com.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 value
        Since:
        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 class com.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 into
        column - the column to add
        Returns:
        given column
        Throws:
        IllegalStateException - if Grid's current selection model renders a selection column, and index 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
      • 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
      • 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
      • getFooterRowCount

        public int getFooterRowCount()
        Gets the row count for the footer.
        Returns:
        row count
      • 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.
      • getEscalator

        public Escalator getEscalator()
        Gets the Escalator used by this Grid instnace.
        Returns:
        the escalator instance, never null
      • setWidth

        public void setWidth​(String width)
        Overrides:
        setWidth in class com.google.gwt.user.client.ui.UIObject
      • 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, 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. See ScrollDestination 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
      • 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 via setHeight(String), and behave as a traditional Widget.

        If HeightMode.ROW is given, Grid will make sure that the body will display as many rows as getHeightByRows() defines. Note: If headers/footers are inserted or removed, the widget will resize itself to still display the required amount of rows in its body. It also takes the horizontal scrollbar into account.

        Parameters:
        heightMode - the mode in to which Grid should be set
      • onBrowserEvent

        public void onBrowserEvent​(com.google.gwt.user.client.Event event)
        Specified by:
        onBrowserEvent in interface com.google.gwt.user.client.EventListener
        Overrides:
        onBrowserEvent in class com.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. The subPart identifier is component specific and may be any string of characters, numbers, space characters and brackets.
        Specified by:
        getSubPartElement in interface SubPartAware
        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. 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 with subElement are the same as interactions with the element identified by the return value. For example a button can return an identifier for the root element even though a DIV inside the button was passed as subElement because interactions with the DIV and the root button element produce the same result.

        Specified by:
        getSubPartName in interface SubPartAware
        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.
      • 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)
        Test if a row is selected.
        Parameters:
        row - a row object
        Returns:
        true, if the current selection model considers the provided row object selected.
      • 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 the getSelectedRows() method.

        Returns:
        a selected row reference, or null, if no row is selected
        Throws:
        IllegalStateException - if the current selection model is not an instance of SelectionModel.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 interface HasSelectionHandlers<T>
        Parameters:
        handler - a SelectionHandler
        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.
        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 reference
        direction - 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 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 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 the onEvent method of a handler returns true, subsequent handlers are not invoked.
        Parameters:
        index - the index to insert the handler to
        handler - 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 interface DeferredWorker
      • 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, or null 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, or null 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 enabled
        IllegalStateException - 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 enabled
        IllegalStateException - 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 enabled
        IllegalStateException - 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 disable
        IllegalStateException - 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 - if saveCaption is null
      • 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 - if cancelCaption is null
      • 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 class com.google.gwt.user.client.ui.Composite
      • onDetach

        protected void onDetach()
        Overrides:
        onDetach in class com.google.gwt.user.client.ui.Composite
      • onResize

        public void onResize()
        Specified by:
        onResize in interface com.google.gwt.user.client.ui.RequiresResize
        Overrides:
        onResize in class com.google.gwt.user.client.ui.ResizeComposite
      • add

        @Deprecated
        public void add​(com.google.gwt.user.client.ui.Widget w)
        Deprecated.
        Grid does not support adding Widgets this way.

        This method is implemented only because removing widgets from Grid (added via e.g. Renderers) requires the HasWidgets interface.

        Specified by:
        add in interface com.google.gwt.user.client.ui.HasWidgets
        Parameters:
        w - irrelevant
        Throws:
        UnsupportedOperationException - always
      • clear

        @Deprecated
        public void clear()
        Deprecated.
        Grid does not support clearing Widgets this way.

        This method is implemented only because removing widgets from Grid (added via e.g. Renderers) requires the HasWidgets interface.

        Specified by:
        clear in interface com.google.gwt.user.client.ui.HasWidgets
        Throws:
        UnsupportedOperationException - always
      • iterator

        @Deprecated
        public Iterator<com.google.gwt.user.client.ui.Widget> iterator()
        Deprecated.
        Grid does not support iterating through Widgets this way.

        This method is implemented only because removing widgets from Grid (added via e.g. Renderers) requires the HasWidgets interface.

        Specified by:
        iterator in interface com.google.gwt.user.client.ui.HasWidgets
        Specified by:
        iterator in interface Iterable<T>
        Returns:
        never
        Throws:
        UnsupportedOperationException - always
      • remove

        @Deprecated
        public boolean remove​(com.google.gwt.user.client.ui.Widget w)
        Deprecated.
        Grid does not support removing Widgets this way.

        This method is implemented only because removing widgets from Grid (added via e.g. Renderers) requires the HasWidgets interface.

        Specified by:
        remove in interface com.google.gwt.user.client.ui.HasWidgets
        Returns:
        always false
      • doAttachChildren

        protected void doAttachChildren()
        Overrides:
        doAttachChildren in class com.google.gwt.user.client.ui.Widget
      • doDetachChildren

        protected void doDetachChildren()
        Overrides:
        doDetachChildren in class com.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 is null;
        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 row
        visible - true to show the details, or false 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 height
        height - 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 interface com.google.gwt.user.client.ui.Focusable
      • setAccessKey

        public void setAccessKey​(char key)
        Specified by:
        setAccessKey in interface com.google.gwt.user.client.ui.Focusable
      • setFocus

        public void setFocus​(boolean focused)
        Specified by:
        setFocus in interface com.google.gwt.user.client.ui.Focusable
      • setTabIndex

        public void setTabIndex​(int index)
        Specified by:
        setTabIndex in interface com.google.gwt.user.client.ui.Focusable
      • focus

        public void focus()
        Description copied from interface: Focusable
        Sets focus to this widget.
        Specified by:
        focus in interface Focusable
      • 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 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
      • 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