Vaadin:8.1.1
Chrome 60.0.3112.78
I am trying to migrate some code from vaadin 7.7 to 8.1 and now I am trying to set some client side acceptance critera for drops in treeGrid. I am using below code. You can use any object in place of TOC.
[code]
TreeGrid tocTree = new TreeGrid();
tocTree.addColumn(tocVO → tocVO.getCaption())
.setStyleGenerator(tocVO → tocVO.getName());
tocTree.setSelectionMode(Grid.SelectionMode.SINGLE);
tocTree.removeHeaderRow(tocTree.getDefaultHeaderRow());
tocTree.setStyleName(“edit-toc-tree”);
tocTree.setSizeFull();
TreeGridDragSource dragSource = new TreeGridDragSource<>(tocTree);
dragSource.setEffectAllowed(EffectAllowed.MOVE);
dragSource.setDragDataGenerator(“tocItemType”, tocVO → tocVo.getName());
dragSource.addGridDragStartListener((GridDragStartListener) event → {
Set draggedItems = event.getDraggedItems();
if (draggedItems.size() > 0) {
TOC draggedItem = draggedItems.iterator().next();
dragSource.setDragData(draggedItem);//set only one node
}
});
TreeGridDropTarget<TOC> dropTarget = new TreeGridDropTarget<>(tocTree, DropMode.ON_TOP_OR_BETWEEN);
dropTarget.setDropEffect(DropEffect.MOVE);
dropTarget.setDropCriteriaScript(
"console.log(event);"
+ "if (event.dataTransfer.types.length > 0) {"
+ "console.log('SOME TYPE FOUND');"
+ "if(event.dataTransfer.types['tocItemType']
===‘ARTICLE’){"
+ “return true;”
+ “}”
+ “}”
// Otherwise cancel the event
+ “return false;”
);
[/code]Now I am setting some data in line 10. But I am not getting anything in event.dataTransfer.types. I have tried several combinations in script and dataGenerators/ manually setting the data etc. but to no avail. Is there anything which I am missing here to create a client side accept criteria.