I have a grid (not pro) with drag-n-drop. I use


This goes to the function, but before the item is actually moved. How do I then extract the contents of the grid to an array so I can update other gadgets according the grid order?

Drag and drop item

Goto onDrop function

Extract grid order to an array

Do some stuff with array

Fill other gadgets from array

return from onDrop function

To catch moment when drag operation starts you can use “onBeforeDrag” event (available in pro version only). onBeforeDrag event passes the following parameter:
id - id of the dragged row.
grid.attachEvent(“onBeforeDrag”, function(id){});
This event returns: true - confirms drag-and-drop; false - denies drag-and-drop (operation will not start); any other text value - used as visual representation of the dragged row

To retrive necessary information from sourse grid you can use parameters of HandleDropDNSServer function. “onDrop” event passes the following parameters:
sId - id of the source item;
tId - id of the target item;
dId - id of the dropped item (has sense for mercy drag-n-drop);
sObj - source grid object;
tObj - target grid object;
sCol - index of the column from which drag started;
tCol - index of the column in which drop occurs.
grid.attachEvent(“onDrop”, function(sId,tId,dId,sObj,tObj,sCol,tCol){});

Please find more inforamtion here dhtmlx.com/docs/products/dhtmlxG … rid_mandnd

   I guess I should have explained more: it’s in the same grid.  Just moving items up/down.  onDrop goes to the function, but the items have not been moved yet.  When return from the onDrop function, they get moved and it’s too late to catch the event now.

   So if I drag an item from position 5 to position 2 in the same grid, how do I now scan the grid once it’s dropped? 


The onDrop event in grid occurs after node was moved, on moment of event , the row in grid already moved to the new position ( it may be not reflected in GUI yet, but the inner model already updated , so any API calls will state that row is at new position )

If you need to catch moment exactly before moving you can use “onDrag” event, the moment exactly after moving - “onDrop” event

Beware that moving row by moveRowUp and moveRowDown commands will not trigger events at all.

>> how do I now scan the grid once it’s dropped
If you call serialization or any other method from onDrop event it will reflect the new order of rows.

I am not using Pro version.

Yes, onDrop is supposed to be after the item was dropped and grid updated, then function called.  But what are we to do when not using Pro version?

Ok, this is driving me nuts.

I just tried it in a different grid, worked perfectly.  But still not in the original grid.  Hmmmmm…


If you can localize problematic case in a separate sample - you can send it to support@dhtmlx.com ( or link to the page where issue can be reconstructed )