PDA

View Full Version : drag and drop remove of invitation



yyogev
8 Jan 2012, 12:20 AM
Hello,

I have a grouping grid where I want to allow the users to move items between groups.
Since the groups are created dynamically, I did not think it made sense to create a list of groups after each loading of the store, but rather had all the items belong to a single ddGroup.
All my grid records use a child class of DragSource, and the group rows create a DropTarget instance for each group header row.

When I drag a record over itself or other records, the drag icon is the 'dropNotAllowed' icon (red "no entry"), which is OK, as it hovers over DragSource, not DragTarget.
When I drag a record over a group header, the drag icon is changed to the 'dropAllowed' icon (green V), as it hovers over a DragTarget.

What I wanted is this: when I drag a record its own group header, I don't want the drag icon to change. In the terms used in the Sencha docs concept article on drag and drop: I don't want to show the drop invitation.
In my child class, I tried to call onDragOut() in afterDragEnter(), as seen in the above article, but this did not work. Doing this in beforeDragEnter() did not work either.

Here's my code:


beforeDragEnter : function(target, e, id)
{
// Allow dropping the record if not dropping it on its own group header
if (target.group_id === this.group_id)
return false;
return true;
},


afterDragEnter : function(target, e, id)
{
// Allow dropping the bug if not dropping it on its own group header
if (target.group_id === this.group_id)
{
this.onDragOut(target, e, id);
return false;
}
return true;
}


Thanks,