public interface FolderDropHandler extends EventHandler
Modifier and Type | Method and Description |
---|---|
void |
onFolderDrop(FolderDropEvent event)
Process a drop of one or more nodes on a TreeGrid folder.
|
void onFolderDrop(FolderDropEvent event)
This method can be overridden to provide custom drop
behaviors and is a more appropriate override point than the lower level Canvas.drop()
handler.
If this is a self-drop, nodes are simply reordered. An "update" operation will be submitted
to update the parentId
field of the moved node(s).
For a drop from another widget, TreeGrid.transferDragData()
is called which, depending on the dragDataAction
specified on the source widget, may either
remove the source nodes from the original list (dragDataAction:"move"
) or just provide a copy to this tree
(dragDataAction:"copy"
).
In either case the new row(s) appear in the folder
at the
index
specified by the arguments of the same name.
If this grid is databound, the new nodes will be
added to the dataset by calling DataSource.addData()
. Further, if
the new nodes were dragged from another databound component, and addDropValues
is true, getDropValues
will be called for every item being dropped.
As a special case, if the sourceWidget
is also databound and a foreignKey
relationship is declared from the
sourceWidget
's DataSource to this TreeGrid's DataSource, the interaction will be treated as a "drag
recategorization" use case such as files being placed in folders, employees being assigned to teams, etc. "update"
DSRequests will be submitted that change the foreignKey field in the dropped records to point to the tree folder that
was the target of the drop. In this case no change will be made to the Tree data as such, only to the dropped records.
For multi-record drops, Queuing is automatically used to combine all DSRequests into a single HTTP Request (see QuickStart Guide, Server Framework chapter). This allows the server to persist all changes caused by the drop in a single transaction (and this is automatically done when using the built-in server DataSources with Power Edition and above).
If these default persistence behaviors are undesirable, Call FolderDropEvent.cancel()
from within onFolderDrop(com.smartgwt.client.widgets.tree.events.FolderDropEvent)
to cancel them, then and implement your
own behavior, typically by using grid.updateData() or addData() to add new records.
NOTE: the records you
receive in this event are the actual Records from the source component. Use DataSource.copyRecords()
to create a copy before modifying the records
or using them with updateData() or addData().
event
- the event