PDA

View Full Version : Issues with DND Tree and Nodes



programmatic
11 Feb 2010, 7:57 AM
I am creating a tree with Drag and drop capabilities however I do not want to allow certain nodes to be dropped. My tree consists of 2 types of nodes:
1)Leaf node
2)Folder node containing 2 nodes, Yes and No. The Yes/No nodes are allowed children

I want to allow dropping for my Yes/No nodes ONLY. I also disabled dragging the Yes/No nodes. Not the Folder node. I do not want siblings for the Yes/No nodes, only children.

Also, why can't I drag and drop to the bottom of the tree if the last node is expanded? I also noticed this to be true in the Explorer Demo. If I expand the last node, I am unable to drop another folder to the bottom unless I collapse that last node then move down.




TreePanelDropTarget target = new TreePanelDropTarget(treePanel)
{
@Override
protected void showFeedback(DNDEvent event)
{
super.showFeedback(event);
TreeNode overItem = tree.findNode(event.getTarget());
if(overItem.getModel().get("type").equals(FOLDERNODE))
{
event.setCancelled(true);
event.getStatus().setStatus(false);
//event.getDropTarget().setFeedback(Feedback.APPEND);

}

}

};
target.setAllowSelfAsSource(true);
target.setFeedback(Feedback.BOTH);



Using this code, I am able to disallow dropping to the folder node, however if this folder node is the last node on the tree, it doesn't allow dropping after the node (whether it's expanded or collapsed)

programmatic
11 Feb 2010, 11:54 AM
Most of all, I'm wondering if there is a way for me to disable dropping to a certain node in the tree, but still drop to a place below that node, and that node is last in the tree. How can I achieve this?

programmatic
16 Feb 2010, 6:55 AM
No one?

tortexy
16 Feb 2010, 11:18 AM
I'd try the code from: http://www.extjs.com/examples/explorer.html#treetotree



TreePanel<ModelData> tree2 = new TreePanel<ModelData>(store) {
@Override
protected boolean hasChildren(ModelData model) {
if ("My Files".equals(model.get("name")) || model instanceof Category) {
return true;
}
return super.hasChildren(model);
}
};


I have used at once, as far as I rememer, if the function returns "true", that item may have child - meaning can be dropped on.

Try that.