dhtmlxGrid enableMercyDrag enabled with move

Hi,

I have two grids, and I allow both of them to allow drag/drop feature.
If moving items from one grid to another, I would like it to keep the items in source grid.
I used enableMercyDrag to achieve this, however, I would also like to reorder items in the grid by drag and drop if it’s a same grid.
In this case, since I have a enableMercyDrag enabled, it creates new entry.

Is there anyway to prevent this or is there any way to achieve what I want?

Grid1->Grid2 - allow to drag with mercy (keep the item in Grid1)
Grid1->Grid1 - allow to move, not copy

Thanks in advance.

Please, try to add the following code:

Grid1.attachEvent("onDrag", function(sId,tId,sObj,tObj,sInd,tInd){ if(sObj==tObj)return true; else { var val=new Array() for (var i=0; i<sObj.getColumnsNum(); i++){ val[i]=sObj.cells(sId,i).getValue(); } tObj.addRow(tObj.uid(),val,tObj.getRowIndex(tId)) return false; }; });

Thanks for the reply.
However this code does work as I desire.

What I want:
Grid1->Grid2 - allow to drag with mercy (keep the item in Grid1)
Grid1->Grid1 - allow to move, not copy

Your code allows to mercy drag for Grid1 (which creates the duplicate).

Any help would be appreciated.
Thanks advance.

Please, try to add the similar code to the Grid2

Hi Sematik,

Grid2 is behaving as I want, however Grid1 does not.

I want to allow copying items from Grid1 to Grid2, but also likes to move to different position within Grid1 (without duplicating). Basically allowing to change sort order in Grid1.

Ex.

Grid1:
Item1
Item2
Item3

  1. Drag Item1 from Grid1 and drop on to Grid2
    -> Both Grid1 and Grid2 should have Item1

  2. Drag Item3 in Grid1 to the position of Item1
    -> Item3 moves to the position of Item1 and pushes Item1 and Item2 down the order.
    However, this is not possible due to mercydrag, it copies the Item3 and there are two Item3 in Grid1.

Hope this makes clear.

Thank you.

Nevermind, I set the enablemercydrag to false and your first solution worked.

thanks