Class GridDropEvent<T>

  • Type Parameters:
    T - The Grid bean type.
    All Implemented Interfaces:
    Serializable

    @DomEvent("grid-drop")
    public class GridDropEvent<T>
    extends ComponentEvent<Grid<T>>
    Drop event that occurs on the Grid or its rows.
    Author:
    Vaadin Ltd.
    See Also:
    Grid#addDropListener(GridDropListener), Serialized Form
    • Constructor Detail

      • GridDropEvent

        public GridDropEvent​(Grid<T> source,
                             boolean fromClient,
                             @EventData("event.detail.dropTargetItem")
                             elemental.json.JsonObject item,
                             @EventData("event.detail.dropLocation")
                             String dropLocation,
                             @EventData("event.detail.dragData")
                             elemental.json.JsonArray dragData)
        Creates a grid drop event.
        Parameters:
        source - Component that was dragged.
        fromClient - true if the event originated from the client side, false otherwise
        item - The item on which the drop occurred, from detail.dropTargetItem.
        dropLocation - Drop location from detail.dropLocation.
        dragData - Drag data from detail.dragData.
    • Method Detail

      • getDropTargetItem

        public Optional<T> getDropTargetItem()
        Get the row the drop happened on.

        If the drop was not on top of a row (see getDropLocation()) or GridDropMode.ON_GRID is used, then returns an empty optional.

        Returns:
        The item of the row the drop happened on, or an empty optional if drop was not on a row
      • getDataTransferData

        public Optional<String> getDataTransferData​(String type)
        Get data from the DataTransfer object.
        Parameters:
        type - Data format, e.g. text/plain or text/uri-list.
        Returns:
        Optional data for the given format if exists in the DataTransfer, otherwise Optional.empty().
      • getDataTransferText

        public String getDataTransferText()
        Get data of any of the types "text", "Text" or "text/plain".

        IE 11 transfers data dropped from the desktop as "Text" while most other browsers transfer textual data as "text/plain".

        Returns:
        First existing data of types in order "text", "Text" or "text/plain", or null if none of them exist.
      • getDataTransferData

        public Map<String,​String> getDataTransferData()
        Get all of the transfer data from the DataTransfer object. The data can be iterated to find the most relevant data as it preserves the order in which the data was set to the drag source element.
        Returns:
        Map of type/data pairs, containing all the data from the DataTransfer object.