TableDnD
TableDnD copied to clipboard
Drag boundaries
Hi Is it possible to set a drag boundary ? So you can't drag past that boundary?
Thanks
No this isn't possible at the moment.
You could provide an onDrop method and see if the mouse is out of the boundary and not allow the drop if so. I think that's the only approach at the moment.
Thanks for the reply. I'm using an onDrop to update various values within the row, but I've not been able to get it to stop the drop when its above the area.. how do I get it to stop dropping and what happens to the row ? does it return to it's original position ? Thanks
in my onDrop I've added:
if (group.attr('id') === undefined) {
$('#' + row.id).insertAfter('#lastGroup');
}
This isn't working. I can see row.id = 3 and I've used insertAfter with in other pages, so I'm stuck as to why this doesn't work..
Any ideas ?
You're right. I've just had a play and it isn't possible to prevent dropping in onDrop
. Looking through the code (I'm afraid it's been a while), I think you have to call insertBefore
. I seem to remember that inserting table rows was tricky and didn't work quite the way that you might expect.
Another approach might be to add the "nodrop"
class to the rows you don't want it to be dropped onto? You could potentially do this dynamically in the onDragStart
?
If that's no good, then I suggest you put a breakpoint on the insertBefore
lines and examine the parent object. This should give you what you need to tweak the code above so that it works as you'd like.
Hope this helps!
Thanks I seem to have go this working. All my rows have unique ID's, So I'm finding my top rows ID, and the returning false if the ID of the currentRow === the top ID.