Stop duplicates in target grid when draging multipule items


Thanks for your quick reply :slight_smile:



I am using this code to check the items dragged into grid 2 from grid 1.



mygrid3.attachEvent(“onDrag”,function(sid,tid){
  if(mygrid3.getRowById(sid)){
    return false;
  }else{
    return true;
  }
}); 



How do I make it work for “multiple items” dragged into the target grid?



----------------------------------------------------------------------------------------------------------------------------------------



I have two identical grid structures.
I am dragging multipule selected items from grid 1 into grid 2.

Q: How can I stop duplicate items from ending up in grid 2 without stopping the other selected data from being added?



----------------------------------------------------------------------------------------------------------------------------------------



You can attach custom code to the onDrag event, which will get list of draged items ( incoming parameter ) , check which of them not exist in target grid (grid.getRowById returns null for not existing rows), after that execute moveRow ( or moveRowTo ) command against all rows , which need to be moved and return false to block original d-n-d action. 

As result the d-n-d will be blocked, but necessary rows moved ( by moveRow calls ) 



 

Unfortunately it can’t be done in such simple manner for group of rows, because only sinlge event will fire for all dragged rows, and you can block or confirm all rows at once.
The solution with custom moveTo calls , proposed originally still can be used in your way.
Alternativly you can try to use next code

mygrid3.attachEvent(“onDrag”,function(sid,tid){
var ids=sid.split(",");
for (var i=ids.length-1; i>=0; i–){
if(mygrid3.getRowById(ids[i]))
mygrid3.dragContext.sid.splice(i,1); // delete draged row from list of draged
return true;
});