Hello,
I have a treegrid and a normal grid on my page to move items from the treegrid to the normal one using drag and drop.
To prevent double entries on my destination grid, I implemented a drag function that is called by the onDrag event of the grid.
Whenever I D&D items without childs from the tree to the grid, the event fires, returns false and does not allow dropping the item as expected, this works perfectly.
When I D&D items that have childs, the event fires, iterates all childs and checks every child if it is already existing in the destination grid. If it is already existing, the function returns false but then the child is dropped anyway. Why?
Here is my function:
function drag_function (source_item_id, target_item_id, source_grid_object, target_grid_object, source_column_index, target_column_index) {
// * Single Select D&D Check: No Drag and Drop of already assinged items
if ((source_item_id.indexOf(",") == -1)) {
// * Get Childs of selected item
var child_items = source_grid_object.getAllSubItems(source_item_id);
// * Check if selected user has childs
if (child_items != "") {
// * Check all childs if they are already assigned to destinationlist
var childs = child_items.split (",");
;childs.foreach( function( k, v ) {
if(typeof(v) !="undefined") {
if (target_grid_object.isItemExists(v)) {
// ********** To be done: Error, Return false does not prevent from adding double items!! **********
return false;
// ********** To be done: Error, Return false does not prevent from adding double items!! **********
}
}
});
}
// * If item has no childs, check only if his ID already exists
else {
if (target_grid_object.isItemExists(source_item_id)) {
return false;
}
}
return true;
Thanks for your help!