Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Alexandre Morin on Aug 14, 2008 02:40
open dhtmlx forum
Drag and Drop an item from one grid to another specific one

Hi,

I've got a page with 4 simple grids on it. Now I'd like to allow item drag&drop from grid number one to number two (and reverse), and from grid number three to grid number four (and reverse).
An item from grid number one shouldn't be dropped in grid number three or four.
An item from grid number three shouldn't be dropped in grid number one or two.
...

I've been trying to use this method but it does not seem to work properly :

mygrid1.setDragHandler(function(sid, tid, sourceGrid, targerGrid)
{
    if(sourceGrid == mygrid2){
        return true;
    } else {
        alert("You can't add an item from this grid!");
        return false;
    }
});

So I'd like to know if there is a specific function or another way so I can check the source grid and allow the item to be dropped or not?
Answer posted by Support on Aug 14, 2008 03:05
Actually , the code which you are using is correct. But if you are using grid 1.6 you need to use different event declaration syntax. 

mygrid1.attachEvent("onDrag",function(sid, tid, sourceGrid, targerGrid){
    if(sourceGrid == mygrid2){
       return true;
    } else {
       alert("You can't add an item from this grid!");
       return false;
    }

})

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Managed_Drag_and_Drop.html#grid_mandnd