Disable drop on some items but not others

I have been through the docs and searched the forum I am not sure how I can accomplish this. I want to mimic a file system with folders and files. I want to disable the ability to drop a “File” on another “file” and only allow “files” to be dropped on “folders”.

Is there a function or attribute that I can set to enable/disable the ability for an item to have other items dropped on them? As a n00b to dhtmlx a code example would be of tremendous help.

Many, many TIA

Coz

You can use “onBeforeDrag” and “onDragIn” event to control which item should be draggable in Tree.
List of available events docs.dhtmlx.com/doku.php?id=dhtm … s_handling
Drag-and-drop documentation docs.dhtmlx.com/doku.php?id=dhtm … p_handling
Managing drag and drop in grid (you can use the same approach in Tree too) docs.dhtmlx.com/doku.php?id=dhtm … and_drop&s[]=drag&s[]=and&s[]=drop

You can use “onBeforeDrag” and “onDragIn” event to control which item should be draggable in Tree.

With all due respect, that does not address my original query. If it does I do not see how. Everything should be dragable, I want to prevent items from being dropped on some items (folders).

Let me restate the question:

How do I prevent items from being dropped on certain predetermined items in a tree?

I have scoured the documentation and it seems that this is not possible. My purchase decision was based on the ability to do this. Oh well, live and learn.

You can use following code:

tree.attachEvent("onDragIn",function(dId,lId,id,sObject,tObject){ if (tree2.getLevel(lId)==1) return false return true; });

I have the exact same requirement. I’m going to try out the code that Olga posted and see if it works.

I want to disable the ability to drop a “File” on another “file” and only allow “files” to be dropped on “folders”.

tree.attachEvent(“onDrag”,function(sourceId,targetId){
return this.hasChildren(targetId);
});

Hi guys,

I want to disable the ability to drop a “File” on another “file” and only allow “files” to be dropped on “folders”.

I do this, which works for me:

In my xml file I include userdata for each item that - among other things - identifies an item as folder or file. I use the dragging events, as pointed out by Olga to examine the userdata of the item I am currently hovering over. At that point I know if it is a valid drop location.

I do not see Dhtmlx respond to the return values of onDragIn. Return true or return false does not provide me with the expected result (or I have failed to identify the behaviour). Instead, I change the css of the row to highlight it only if it is a valid drop location. During onDrop of perform the same verification and cancel or proceed the drop.

Regards,

Joost

brugmanjoost
Could you explain, what kind of issue you have? To identify it is necessary to get more info.
F.e. attach your code (currently part of it). May be you will not need to put userdata to all your items.