com.vaadin.ui.components.grid.

Class GridDropTarget<T>

    • Constructor Detail

      • GridDropTarget

        public GridDropTarget​(Grid<T> target,
                              DropMode dropMode)

        Extends a Grid and makes it's rows drop targets for HTML5 drag and drop.

        Parameters:

        target - Grid to be extended.

        dropMode - Drop mode that describes the allowed drop locations within the Grid's row.

        See Also:

        GridDropEvent.getDropLocation()

    • Method Detail

      • getGrid

        public Grid<T> getGrid()

        Gets the grid this extension has been attached to.

        Returns:

        the grid for this extension

        Since:

        8.2

      • getDropMode

        public DropMode getDropMode()

        Gets the drop mode of this drop target.

        Returns:

        Drop mode that describes the allowed drop locations within the Grid's row.

      • setDropAllowedOnRowsWhenSorted

        public void setDropAllowedOnRowsWhenSorted​(boolean dropAllowedOnSortedGridRows)

        Sets whether the grid accepts drop on rows as target when the grid has been sorted by the user.

        Default value is true for backwards compatibility with 8.1. When true is used or the grid is not sorted, the mode used in setDropMode(DropMode) is always used.

        false value means that when the grid has been sorted, the drop mode is always DropMode.ON_GRID, regardless of what was set with setDropMode(DropMode). Once the grid is not sorted anymore, the sort mode is reverted back to what was set with setDropMode(DropMode).

        Parameters:

        dropAllowedOnSortedGridRows - true for allowing, false for not allowing drops on sorted grid rows

        Since:

        8.2

      • isDropAllowedOnRowsWhenSorted

        public boolean isDropAllowedOnRowsWhenSorted()

        Gets whether drops are allowed on rows as target, when the user has sorted the grid.

        Returns:

        whether drop are allowed for the grid's rows when user has sorted the grid

        Since:

        8.2

      • addGridDropListener

        public Registration addGridDropListener​(GridDropListener<T> listener)

        Attaches drop listener for the current drop target. GridDropListener.drop(GridDropEvent) is called when drop event happens on the client side.

        Parameters:

        listener - Listener to handle drop event.

        Returns:

        Handle to be used to remove this listener.

      • setDropThreshold

        public void setDropThreshold​(int threshold)

        Sets the threshold between drop locations from the top and the bottom of a row in pixels.

        Dropping an element

        The value only has an effect when drop mode is set to DropMode.ON_TOP_OR_BETWEEN.

        Default is 5 pixels.

        Parameters:

        threshold - The threshold from the top and bottom of the row in pixels.

      • getDropThreshold

        public int getDropThreshold()

        Gets the threshold between drop locations from the top and the bottom of the row.

        Returns:

        The threshold in pixels.

      • getState

        protected GridDropTargetState getState()

        Description copied from class: AbstractClientConnector

        Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.

        As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use getState(false) to avoid marking the connector as dirty.

        Overrides:

        getState in class DropTargetExtension<Grid<T>>

        Returns:

        The shared state for this connector. Never null.

      • remove

        public void remove()

        Description copied from interface: Extension

        Remove this extension from its target. After an extension has been removed, it cannot be attached again.

        Specified by:

        remove in interface Extension

        Overrides:

        remove in class AbstractExtension