jQGrid Drag and Drop Row Check
drag-and-drop, jqgrid, jquery-ui-draggable
Solution
The example of the usage could be about the following
$("#grid1").jqGrid('gridDnD', {
connectWith: '#grid2',
beforedrop: function (ev, ui, getdata, $source, $target) {
var names = $target.jqGrid('getCol', 'name2');
if ($.inArray(getdata.name2, names) >= 0) {
// prevent data for dropping
ui.helper.dropped = false;
alert("The row is already in the destination grid");
}
}
});
On the demo you would be unable to drop the rows "test1" from the first grid to the second one:
Other rows will be dropped without any problems.
Problem
I have my primary grid dragging/dropping rows correctly into a secondary grid. My question is, how do I perform a check just before the row is dropped into my secondary grid, which determines if the row I am attempting to drop is already there? If it is already there in the secondary grid, don't let the user drop it there, basically stop the drag/drop function. I'm thinking I can grab the key value from the row I am attempting to drop. Then, check to see if that value already exists as the key value in one of the rows I already dropped. I'm assuming I will have to use this function in some way: ``` beforedrop : function(e,ui,data,source,target) { } ``` OR this function: ``` ondrop: function (ev, ui, getdata) { } ``` Anyone have any ideas?