Flex 2.0.1 Tree with Spring Loaded Folders (Update 2)
February 26, 2007
I’ve updated the Flex 2.0.1 Tree with Spring Loaded Folders code to take care of a couple small bugs, plus added some features. Support for optional restricted operations during both drag and drop (including inheritance support). Optional drag proxy when dragging multiple items. Operation restriction when dragging into originating node (into self).
I decreased the auto opening sensibility as it was a bit reactive, for example if you moved over a node then directly above it, it would still trigger the open sequence (sporadic).
I added a common function to show a restricted operation cursor, this allows one to constrain certain nodes/leafs from being dragged, or dragged into.
There is an optional inheritRestrictionsDrag property when set to true all children inherit it’s parents settings. This allows you to mark the top level parent with the restriction and have all children follow the rules.
I added functionality so one could specify that certain nodes/leafs can’t be dragged at all. Also has an optional inheritRestrictionsDrop property, same rules apply as above.
Your data source should have acceptDrag or acceptDrop to take advantage of the above functionality. I had thought about creating a data descriptor for these, but that may have been restrictive for some. So basically if acceptDrag = false then you can’t drag the item, and if acceptDrop = false then you can’t drop into an item.
I added support for click open where if true and the user clicks anywhere on the itemrenderer then it’ll open or close respectively. This is optional via the property openOnClick.
I’ve replaced the @isBranch, an xml specific directive with “dataDescriptor.isBranch(selectedItem)”.
I’ve added an optional groupDragProxy property and a groupDragProxyLabel. When set to true and multiple selection dragging is occurring the drag proxy image will show only one item with a optional item count, as opposed to the stacked items method. The label text for the drag proxy image can be set via the groupDragProxyLabel property with an optional “[#]” where the [#] is replaced with an item count. There is a new class which provides this support ListItemGroupedDragProxy which is an extension of ListItemDragProxy. If you don’t need/like it, it may be safely removed by deleting the overridden function dragImage.
I added support to stop the opening indication animation and subsequent actions when a node is being dragged into itself, it’ll now show a restricted operation indication.
I’ve added access to the internal dropData of the tree. It’s not used all over the place but this will officially rule out support for Flex 2.0. I’m sure there are way’s to replace the calls with other supported calls for those that wish to find a solution. For Flex version 2.0.1 all is well.
New methods include:
Plus the new class as mentioned above.
All the changes are marked with “Update:”. The below sample has been updated to reflect these changes. The previous version will remain unchanged. Ideas and feed back welcome.
Requires Flash 9 player.
Sample and Source : Spring Loaded Folders (Update 2)