[Users] GeoExt LayerContainer with checkbox
Julien-Samuel Lacroix
jlacroix at mapgears.com
Mon Jun 7 22:24:54 CEST 2010
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