mgoerdes
11 Apr 2009, 5:03 AM
hi dev team,
we try to implement a dataset widget, in which the layout can be modified by a user via drag and drop of a tree-element to the target. Therefore we have TabPanel, containing a TabItem, containing a FormPanel to which a user can drag a fieldset. After dragging a fieldset to the FormPanel the user can drag additional fields to the fieldset. Unfortunately the drag/drop of the field to the fieldset does not work, because the DNDManager.getTarget returns the wrong target.
While defining the form, we define a droptarget and set the group DRAG_GROUP_FIELDSET.
DropTarget target = new DropTarget(form) {...}
target.setGroup(DRAG_GROUP_FIELDSET);
After dragging a fieldset to the form, we define the fieldset dynamically and create an additional DropTarget:
DropTarget target = new DropTarget(fieldSet) {
target.setGroup(DRAG_GROUP_FIELD);
No the user should have the possibilty to drag a field to this target, but unfortunately the DNDManaget.getTarget(Element elem) returns the Form, not the Fieldset, because the DOM.isOrHasChild(...) is true for the form. Therefore the handleDragMove returns without result because of the different groups we defined.
After modifying the getTarget method everything works fine for me. But I think, that this is only a quick and dirty solution.
private DropTarget getTarget(DragSource source, Element elem) {
DropTarget t = null;
for (int i = 0, len = targets.size(); i < len; i++) {
DropTarget target = targets.get(i);
if (DOM.isOrHasChild(target.component.getElement(), elem)) {
if (target.getGroup().equals(source.getGroup()))
t = target;
}
}
return t;
}
Can you help me with this?
Regards, Mark
we try to implement a dataset widget, in which the layout can be modified by a user via drag and drop of a tree-element to the target. Therefore we have TabPanel, containing a TabItem, containing a FormPanel to which a user can drag a fieldset. After dragging a fieldset to the FormPanel the user can drag additional fields to the fieldset. Unfortunately the drag/drop of the field to the fieldset does not work, because the DNDManager.getTarget returns the wrong target.
While defining the form, we define a droptarget and set the group DRAG_GROUP_FIELDSET.
DropTarget target = new DropTarget(form) {...}
target.setGroup(DRAG_GROUP_FIELDSET);
After dragging a fieldset to the form, we define the fieldset dynamically and create an additional DropTarget:
DropTarget target = new DropTarget(fieldSet) {
target.setGroup(DRAG_GROUP_FIELD);
No the user should have the possibilty to drag a field to this target, but unfortunately the DNDManaget.getTarget(Element elem) returns the Form, not the Fieldset, because the DOM.isOrHasChild(...) is true for the form. Therefore the handleDragMove returns without result because of the different groups we defined.
After modifying the getTarget method everything works fine for me. But I think, that this is only a quick and dirty solution.
private DropTarget getTarget(DragSource source, Element elem) {
DropTarget t = null;
for (int i = 0, len = targets.size(); i < len; i++) {
DropTarget target = targets.get(i);
if (DOM.isOrHasChild(target.component.getElement(), elem)) {
if (target.getGroup().equals(source.getGroup()))
t = target;
}
}
return t;
}
Can you help me with this?
Regards, Mark