EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Pierre on April 27, 2016, 07:05:26 AM



Title: Disable drop from modal dialog/window
Post by: Pierre on April 27, 2016, 07:05:26 AM
Hello all
is there any option to disable drop of datagrid or treegrid items from modal window to datagrids below that modal window?
I have window and treegrid on it and I want to be able to use only drag/drop on that window but not outside that (modal) window.
I know for the option to accept drop but I have 4 or more datagrids behind modal window and want to avoid lot of code if possible.
Thank you.


Title: Re: Disable drop from modal dialog/window
Post by: Pierre on April 28, 2016, 06:27:26 AM
It is bug for me because I'm able to drop selected datagrid item to "through" window (with other words, if another datagrid is behind current window, I can drop a record on it).
Any comments?


Title: Re: Disable drop from modal dialog/window
Post by: Max Lamda on April 28, 2016, 06:45:49 AM
I had the same problem but I do not see it as a bug.


I added a class dropdynamic to all dropable areas and disabled them, when something happens (tabs change or whatever you application does to put content over other content).

Can be done quite easy then with:

$('.dropdynamic').droppable('disable');


Now you only have to enable the dropable area for the content which just popped up.


Title: Re: Disable drop from modal dialog/window
Post by: Max Lamda on April 28, 2016, 06:50:21 AM
In my application it was just two lines of extra-code in the appropriate functions which change the shown area.


Title: Re: Disable drop from modal dialog/window
Post by: Pierre on April 28, 2016, 07:33:28 AM
OK thank you but do you have some simple example of how you did that?
Thank you again.


Title: Re: Disable drop from modal dialog/window
Post by: Max Lamda on April 28, 2016, 07:38:57 AM
Maybe

$('.dropdynamic').droppable('disable');
$('.dropdynamic').is(':visable').droppable('enable');

already works.

You could use it in the

onBeforeDrag

property of your draggable area....



Title: Re: Disable drop from modal dialog/window
Post by: Pierre on April 28, 2016, 11:30:08 AM
Hello
I created sample:
http://code.reloado.com/oeasyrik1/6/edit#preview

Attached are 2 images where you can see that I'm using Modal window and I need to avoid to drop outside Grid and to drop on datagrid behind.
Could you please implement your code here:
http://code.reloado.com/oeasyrik1/6/edit#source
(you can then click on "Render" to see result.
Thank you.


Title: Re: Disable drop from modal dialog/window
Post by: Max Lamda on April 29, 2016, 01:09:38 AM

Just add

      dropAccept:'.dlg1',
      rowStyler: function() {
      return {class: 'dlg1'};
      },
to your first datagrid


and


      dropAccept:'.dlg2',
      rowStyler: function() {
      return {class: 'dlg2'};
      },

to your second.


http://code.reloado.com/oeasyrik1/7/edit



Title: Re: Disable drop from modal dialog/window
Post by: Pierre on April 29, 2016, 01:20:30 AM
Awesome, thank you so much  ;D


Title: Re: Disable drop from modal dialog/window
Post by: Pierre on April 29, 2016, 01:36:37 AM
Awesome, thank you so much  ;D
OK now I see that you implemented dropAccept and my question was how to disable drop on all grid-s behind current window (I have 4-5 grids and I try to avoid writing dropAccept on all of them..