[Users] How to add multiple components to a tree store node

dustin.r.blankenship at accenturefederal.com dustin.r.blankenship at accenturefederal.com
Tue Jan 6 16:00:27 CET 2015


Have you tried extending the LayerLoader'?

extend: 'GeoExt.tree.LayerLoader',

    createNode: function(attr) {

I had to extend the layer container and use a custom loader. This allowed me to add text and an icon to the node.


-----Original Message-----
From: users-bounces at geoext.org [mailto:users-bounces at geoext.org] On Behalf Of Juliette Fabre
Sent: Tuesday, January 06, 2015 3:20 AM
To: users at geoext.org
Subject: [Users] How to add multiple components to a tree store node

Hello,

I'm trying to add a WMS legend AND an opacity slider to each node of a tree store.
I can add each component separately, but not together ...

It could be something like this, but attr.component = [{...}, {}] raises errors .. :

var tree_store = Ext.create('Ext.data.TreeStore', {
     model: 'GeoExt.data.LayerTreeModel',
     root: {
         expanded: true,
         children: [
         {
             // Base layers
             plugins: ['gx_baselayercontainer'],
             expanded: true,
             text: "Base maps"
         },
         {
             // Overlays
             plugins: [{
                 ptype: "gx_overlaylayercontainer",
                 loader: {
                     createNode: function(attr) {
                         attr.component =
                         [
                         // Add a WMS legend to each node created
                         {
                             xtype: "gx_wmslegend",
                             layerRecord: 
mapPanel.layers.getByLayer(attr.layer),
                             showTitle: false,
                             baseParams: {
                                 // Overrides gif format that is ugly in this case
                                 FORMAT: 'image/png',
                                 LEGEND_OPTIONS: 'forceLabels:off'
                             },
                         },
                         // Add an opacity slider
                         {
                             xtype: "gx_opacityslider",
                             layer: attr.layer,
                             vertical: false,
                             value: 100,
                             //x: 100,
                             //y: 100,
                             width: 200,
                             aggressive: true,
                             listeners: {
                                 change: function(slider, val) {
                                     attr.layer.setOpacity(val/100);
                                 }
                             }
                         }];
                         return
GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
                     }
                 }
             }],
             expanded: true,
             text: "Layers",
         }]
     }
});

Any idea?

Thanks,

Juliette

--
Juliette Fabre
Ingénieur d'Etudes Systèmes d'Information Scientifiques OSU OREME Bât. 22, bureau 220, Université Montpellier 2 Place Eugène Bataillon - CC 22002, 34095 Montpellier Tél : 04 67 14 40 41 data.oreme.org

_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list