Even with loadOnDemand, you can use the isFolderProperty to mark nodes as folders, but also provide an explicit, empty children array to indicate that there are no children to load.
Announcement
Collapse
No announcement yet.
X
-
Ok. The xml structure I am dealing with doesn't support the children as a contained structure. When I retrieve a record from the server, it comes with a field that indicates if it has children (my isFolderProperty).
I guess I could observe this field in a customised datasource, and if it is a leaf, change the field to indicate folder, and manipulate the data to add the empty array, and then manipulate everything back again before sending to the server. Sounds like an awful lot of work to know that I dropped something on a leaf. To be fair, the record is a leaf, not a folder - this doesn't feel like the right solution.
I seem to have everything working ok, though, using the solution from the previous post. It seems much more robust than trying to manipulate the data structures to trick smartclient into thinking that leaves are folders.
Do you see any problems with the approach of overriding drop() instead? Thanks,
Colin
Comment
-
setCanDropOnLeaves
Hi,
I've also been trying to play with the drag and drop, and as the original poster (dareha), I can't drop on leaves even though I've set the property on my trees. What I've seen is that those who complain about this, use (just as I do) the PARENT TreeModelType (and not CHILDREN as in the showcase). So I was wondering if that would be the reason why we can't drop on leaves.
My workaround is to set all nodes as folders, but this shows a '+' icon in front of the node to indicate that we can open it, and I don't want that. You mentioned the fact that we can change this [you can avoid showing an opener control by assuring they have no children], how does it work if we are using the PARENT model?
Another quick question:
Can we set, when creating/adding a node, which leaf icon and folder icon to use, so that we don't have to manually set our custom icon each time the node is moved (using the events). Something like:
setLeafIcon(String icon)
setFolderIcon(String icon) and SmartGWT would automatically use this or the default if null...? I could propose this in the Google Code Issues if you want.
Thank you for your work and quick answers!
Comment
-
Leaves and Folders
Hello,
I've now understood that setting canDropOnLeaves to true won't allow to actually transform a leaf into a folder and adding the new node as its new child, but just throwing the event according to it.
So I've seen in a thread that we have to set the nodes as Folders (setIsFolder(true)), and use the setIsFolderProperty("is_folder") to custom the fact that it has children or not, thus showing the '+' icon or not. But if I do: setAttribute("is_folder", false), then the node is considered as a leaf, and we can't drop children to it...
How am I supposed to configure the tree so that its nodes can accept new children on the fly (just drag n drop on it), but without showing the little '+' icon when no children are left...
Just to know, because it may have an effect, set load on demand is false.
Thank you
Comment
-
SetChildren
Thank you very much for the quick reply, I was looking in the Tree and not in the node itself to set the children, so I just couldn't find the setChildren property to test what you were talking about. And yeah, now I just setChildren(new TreeNode[0]) and it works perferctly! (yeah I'm in SmartGWT).
So again, thank you very much for all the work and quick support, you guys rock! :) (btw, are you just the 2 of you with sanjiv, and sometimes another dev pointing he's nose? because it looks like you are everywhere!)
So as a quick recap:
- setCanDropOnLeave(true) won't transform leaves into folders
- use only folders and not leaves (setIsFolder(true))
- when you want a node to act like a leaf (no '+' sign): node.setChildren(new TreeNode[0])
- use addFolderDropHandler and other drophandlers if needed to set empty node of children when needed
Or whatever are the equivalent in JS for the SmartClient.
Comment
Comment