[Users] enableDD between LayerContainer
Andreas Hocevar
ahocevar at opengeo.org
Thu Mar 4 15:30:24 CET 2010
On 2010-03-04 02:21, Julien-Samuel Lacroix wrote:
> What would be the best way to support the drag-n-drop of the layers in a
> TreePanel to change the layer positions, but between the LayerContainers.
>
> Is it to use LayerNodes instead of LayerContainer and code custom code
> to enable the drag-n-drop support?
> Is it to modify the LayerContainer code to support drag-n-drop between
> containers? (Is it possible?)
>
You do not need to modify any code, it is already supported by the
LayerNode.
Here is how to do it with LayerContainers: First of all, don't forget to
set enableDD to true on the tree, and set allowDrag to false for all
nodes that you don't want to drag (especially the container nodes
themselves). What you then have to do is define a "beforemovenode"
handler on the tree. The handler takes care of making sure that you
change whatever you use for layer grouping (e.g. a layer record field
called "group") so the layer can be added to the new container.
We have done this in the OpenGeo Suite's GeoExplorer. See [1] for the
"beforemovenode" handler and [2] for the filter function that we use to
populate the "background" group.
Regards,
Andreas.
[1]
http://projects.opengeo.org/suite/browser/trunk/geoexplorer/src/client/script/app/GeoExplorer.js?rev=654#L458
[2]
http://projects.opengeo.org/suite/browser/trunk/geoexplorer/src/client/script/app/GeoExplorer.js?rev=654#L365
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list