PDA

View Full Version : Conditional drag & drop between 2 grid views



Araberen
12 Dec 2011, 1:21 AM
Hi,

Everything is in the title. My viewConfig is very simple:


viewConfig: {
plugins: {
ptype: 'gridviewdragdrop'
}
}

This works! But drop is always enabled. So, on the second grid, I add:
enableDrop:false
in the plugins section.

The idea would be to reactivate it after a click on a button (or any other event).
I tried:

myGrid.getView().plugins[0].dragZone.unlock();

myGrid.getView().plugins[0].enable();

myGrid.getPlugin( ??? ) ...

Any idea how to do that?

mitchellsimoens
12 Dec 2011, 12:28 PM
myGrid.getPlugin( ??? ) ...

to use getPlugin, you have to assign an id to the plugin and then pass in the id to getPlugin.

Araberen
12 Dec 2011, 1:04 PM
Yeah, I finally found that I had to add a pluginId property to my plugins. So I wrote:

// code before for the grid
plugins: {
ptype: 'gridviewdragdrop',
pluginId: 'dropuser',
ddGroup: 'groupUserDDGroup',
dragGroup: 'groupUserDDGroup',
dropGroup: 'userListDDGroup',
enableDrag:false
} // code after...

So, here the drop works (for testing).

Then, in my controller, on an event, I can disable the drop:


me.getGroupUsers().getView().getPlugin('dropuser').disable();

That works!

But I want the opposite.
I've read the code of the DragDrop plugin and it seems that once enableDrop (or Drag) is set to false, enable or disable functions won't have any effect on it.

So I had to let the enableDrop config to true and add a listener waiting for the grid to be rendered. The render event is not working, I had to use the afterrender event :


var me = this;

// In my controller
me.control({
'#groupUsers': { // suppose that my grid has an itemId and that I have created a ref in my controller
afterrender: function() {
me.getGroupUsers().getView().getPlugin('dropuser').disable();
}
}
});