TreeGrid/Tree dynamically draggable items in Vaadin 8

Hey all,
Great work on Vaadin 8. Checking out the latest (8.1.0.beta1) Grid/TreeGrid/Tree components today.

I have a common use case for items in my trees (or could be treeGrids): depending on the tree’s data set, sometimes both the parents and childern should be draggable, and other times just the children. I have not yet found that this is possible in Vaadin 8. Either by “tagging” a data item as draggable/not draggable, or by canceling the startDrag() depending on the data item.

Does anyone know if this is doable, yet? Is this funtionality in the works?

In Vaadin 7, I accomplished this by extending the client side Tree component, allowing the startDrag() method to check for a css style attached to the data items via an itemStyleGenerator. If the “no-drag” style was set, then the startDrag() was canceled. No small task, but it worked. I’m hoping for a straightforward solution in Vaadin 8. This is huge for us.

Any comments, ideas or suggestions are greatly appreciated. Thanks!

Hi,

Currently it is not possible to tag items as draggable in the framework. We have already had a discussion about such a feature but there are no plans yet.

Such a feature may be implemented by extending the client side
GridDragSourceConnector
class and overriding its superclass’s
addDraggable(Element)
method. Introduce a condition so that
draggable
attribute wouldn’t be added to each row. This attribute indicates whether an element can be dragged in HTML5 and is by default added to each row by a
callback method
. The
addDraggable()
method receives the [font=courier new]

[/font] element for the given item and so, for example, its styles can be inspected.

I hope this helps,
Adam