T - The Grid bean type.public class GridDragSource<T> extends DragSourceExtension<Grid<T>>
When dragging a selected row, all the visible selected rows are dragged. Note that ONLY visible rows are taken into account.
GridRowDragger,
Serialized FormClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener| Constructor and Description |
|---|
GridDragSource(Grid<T> target)
Extends a Grid and makes it's rows draggable.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addGridDragEndListener(GridDragEndListener<T> listener)
Attaches dragend listener for the current drag source grid.
|
Registration |
addGridDragStartListener(GridDragStartListener<T> listener)
Attaches dragstart listener for the current drag source grid.
|
void |
clearDragDataGenerator(String type)
Remove the generator function set for the given type.
|
SerializableFunction<T,String> |
getDragDataGenerator(String type)
Returns the drag data generator function for the given type.
|
Grid<T> |
getGrid()
Gets the grid this extension has been attached to.
|
protected GridDragSourceState |
getState()
Returns the shared state for this connector.
|
protected GridDragSourceState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
protected void |
registerDragSourceRpc()
Registers the server side RPC methods invoked from client side on
dragstart and dragend events. |
void |
remove()
Remove this extension from its target.
|
void |
setDragDataGenerator(String type,
SerializableFunction<T,String> generator)
Sets a generator function for customizing drag data.
|
addDragEndListener, addDragStartListener, attach, clearDataTransferData, clearDataTransferData, getDataTransferData, getDataTransferData, getDataTransferText, getDragData, getEffectAllowed, getParent, onDragEnd, onDragStart, setDataTransferData, setDataTransferText, setDragData, setDragImage, setEffectAllowed, setPayload, setPayload, setPayloadextend, getSupportedParentType, setParentaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdpublic Grid<T> getGrid()
protected void registerDragSourceRpc()
DragSourceExtensiondragstart and dragend events.
Override this method if you have custom RPC interface for transmitting
those events with more data. If just need to do additional things before
firing the events, then you should override DragSourceExtension.onDragStart() and
DragSourceExtension.onDragEnd(DropEffect) instead.
registerDragSourceRpc in class DragSourceExtension<Grid<T>>public void setDragDataGenerator(String type, SerializableFunction<T,String> generator)
type as the generator is set
here. The function is executed for each item in the Grid during data
generation. Return a String to be appended to the row as type data.
Example, building a JSON object that contains the item's values:
dragSourceExtension.setDragDataGenerator("application/json", item ->
{
StringBuilder builder = new StringBuilder();
builder.append("{");
getParent().getColumns().forEach(column -> {
builder.append("\"" + column.getCaption() + "\"");
builder.append(":");
builder.append("\"" + column.getValueProvider().apply(item) + "\"");
builder.append(",");
});
builder.setLength(builder.length() - 1); // Remove last comma
builder.append("}");
return builder.toString();
}
type - Type of the generated data. The generated value will be
accessible during drop using this type.generator - Function to be executed on row data generation.public void clearDragDataGenerator(String type)
type - Type of the generator to be removed.public SerializableFunction<T,String> getDragDataGenerator(String type)
type - Type of the generated data.public Registration addGridDragStartListener(GridDragStartListener<T> listener)
listener - Listener to handle the dragstart event.GridDragStartEventpublic Registration addGridDragEndListener(GridDragEndListener<T> listener)
listener - Listener to handle the dragend event.GridDragEndEventpublic void remove()
Extensionprotected GridDragSourceState getState()
AbstractClientConnector
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.
getState in class DragSourceExtension<Grid<T>>protected GridDragSourceState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class DragSourceExtension<Grid<T>>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()Copyright © 2020 Vaadin Ltd. All rights reserved.