[Users] GeoExt LayerContainer with checkbox

Julien-Samuel Lacroix jlacroix at mapgears.com
Tue Jun 8 16:26:12 CEST 2010


Hi,

The problem of this code is that selecting all layers in the 
LayerContainer doesn't select the parent checkbox. Any idea?

Thanks
Julien

Julien-Samuel Lacroix wrote:
> Hi,
> 
> I have a Tree with LayerContainers.I want to have a checkbox beside my 
> directory that will allow me check/uncheck all the layers in my 
> LayerContainer in a single click.
> 
> Here's how I do it. Maybe there's a better way, I may have miss something.
> 
> {
>   text: title,
>   layerStore: mapPanel.layers,
>   allowDrag: false,
>   nodeType: 'gx_layercontainer',
>   id: 'layercontainer_'+group,
>   leaf: false,
>   group: group,
>   loader: {
>     filter: function(record) {
>         return record.get('layer').options.group == group;
>     }
>   },
>   checked: false,
>   listeners: {
>     'checkchange' :  function(node, checked)
>     {
>         // If a parent node is unchecked, uncheck all the children
>         if (node.getUI().isChecked()) {
>             node.expand();
>             node.eachChild(function(child){
>               child.ui.toggleCheck(true);
>             });
>         }
>         if (!node.getUI().isChecked())
>         {
>             node.expand();
>             node.eachChild(function(child) {
>                 child.ui.toggleCheck(false);
>             });
>         }
>     }
>   },
> [...snip...]
> }
> 
> 

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the Users mailing list