To do that, I added a "group" property in my layer's javascript object. This way, you can group your layers using this property in the loader :
var treeConfig = [{ text: 'Group 1', nodeType: 'gx_overlaylayercontainer', expanded: true, loader: new GeoExt.tree.LayerLoader({ filter: function(record) { return (record.getLayer().displayInLayerSwitcher == true) && (record.getLayer().group == 'group1'); } }) }, { text: 'Group 2', nodeType: 'gx_overlaylayercontainer', expanded: true, loader: new GeoExt.tree.LayerLoader({ filter: function(record) { return (record.getLayer().displayInLayerSwitcher == true) && (record.getLayer().group == 'group2'); } }) }]; var layerTree = new Ext.tree.TreePanel({ autoScroll: true, enableDD: true, rootVisible: false, root: { nodeType: "async", expanded: true, children: treeConfig }, loader: new Ext.tree.TreeLoader({ applyLoader: false }); Date: Tue, 17 Jan 2012 17:56:52 +0100 From: cowaboon...@gmail.com To: users@geoext.org Subject: [Users] Sub-Nodes on a Tree Hello everyone! I'm back with a question... I'm building a tree with some groups and several layers for each as child nodes... The thing is I read and construct the layers from a database... building it with all as parent nodes is easy, ok, but the hard thing (at least for me) is figuring out how to create that groups, and appending layers as child in the corresponding group... Anyone have an example? Thank you very much in advance! Regards! _______________________________________________ Users mailing list Users@geoext.org http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________ Users mailing list Users@geoext.org http://www.geoext.org/cgi-bin/mailman/listinfo/users