This is what the grids look like when the screen is loaded. During 'ondrop' we are moving data from one to the other with successful display. Although the grids are displaying correctly, when attempting to drag/drop again, the JavaScript is seeing the grid data as if it hadn't changed from the original. This code is in the 'ondrop' for both grids as we want to be able to move them back and forth.
Code: Select all
var source = getObj(pui.dragDropInfo["dd element id"]);
var target = getObj(pui.dragDropInfo["target element id"]);
var sourceRRN = pui.dragDropInfo["dd record number"];
var targetRRN = pui.dragDropInfo["target record number"];
var sourceCnt = source.grid.getRecordCount();
var targetCnt = target.grid.getRecordCount();
var i1=0;
// Load source arrays
var sourceDesc = [];
var sourceItem = [];
for (i1=1; i1<=sourceCnt; i1++) {
sourceDesc[i1] = source.grid.getDataValue(i1, "scDesc");
sourceItem[i1] = source.grid.getDataValue(i1, "scItem");
}
// Load target arrays
var targetDesc = [];
var targetItem = [];
for (i1=1; i1<=targetCnt; i1++) {
targetDesc[i1] = target.grid.getDataValue(i1, "scDesc");
targetItem[i1] = target.grid.getDataValue(i1, "scItem");
}
// Add record to target arrays
targetRRN += 1;
targetDesc.splice(targetRRN, 0, sourceDesc[sourceRRN]);
targetItem.splice(targetRRN, 0, sourceItem[sourceRRN]);
// Remove record from source arrays
sourceDesc.splice(sourceRRN, 1);
sourceItem.splice(sourceRRN, 1);
// Update target grid
for (i1=1; i1<=targetCnt+1; i1++) {
target.grid.setDataValue(i1, "scDesc", targetDesc[i1]);
target.grid.setDataValue(i1, "scItem", targetItem[i1]);
}
// Update source grid
if (source !== target) {
for (i1=1; i1<=sourceCnt; i1++) {
if (sourceDesc[i1] === undefined) {
sourceDesc[i1] = "";
sourceItem[i1] = "";
}
source.grid.setDataValue(i1, "scDesc", sourceDesc[i1]);
source.grid.setDataValue(i1, "scItem", sourceItem[i1]);
}
}
source.grid.render();
source.grid.refresh();
target.grid.render();
target.grid.refresh();
pui.dragDropInfo.cancel = true;