Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Richard White on Nov 17, 2007 05:44
open dhtmlx forum
drag and drop ids

Hi,

we have 1 treegrid and 1 grid set up on a page. we want the user to be able to drag items from the tree into the grid. we have got it set up and working fine. We also have it set up so that once an item has been dragged into the grid, it reloads the item back into the tree but with a different image. therefore once dragged into the grid it then exists in the grid and exists still in the tree.

this is how we want it however, when the user attempts to drag the same item again from the tree into the grid we dont want it to add it again (as it already exists in the grid). we have tried to set up an onrowcreated handler to test if the id of the row created already exists in the grid, if so then delete it from the grid. however we have noticed that for some odd reason, instead of creating an error to say id already exists in grid, your grid just creates a unique id for the item, therefore there is no way we can check whether the item being dragged already exists in the grid

we also tried using the idsource in the drophandler but this again comes up with very weird and untrue ids.

please can you give directions on how we can achieve this

thanks
Answer posted on Nov 19, 2007 01:17
drag and drop provide two events

3 events

onDragIn - source item drage over potential target
onDrag - - item droped on target, but not processed yet  - original SID used
onDrop - item droped on target, and processed -  if  SID was non unique,  new  value used as param of event



In your case onDrag event can be used

grid.setDragHandler(function(sid,tid,sgrid,tgrid){
    if (tgrid.getRowById(sid)) return false; // row already exists
    return true;
})