[Users] treePanel questions

Matt Priour mpriour at kestrelcomputer.com
Wed Nov 10 20:21:07 CET 2010


....
> var container_1 = new GeoExt.tree.LayerContainer({     // group 1
>                         text: "First thematic group",
>                         layerStore: mapPanel.layers,
>                         loader: {
>                                  //param: "LAYERS"
>                                   group: 'grupo1',
>                                   filter: function () {
>                        //           ??
>                                   }
>                        }
> });
> I have seen somewhere 'record' as function argument, but I don't get
> where that comes from. I suppose it referes to any layerRecord (using
> perhapt a group array). I wouldn't need that, because I will customize
> each layerContainer indivudually.
....

'filter' is a function which is run for each record of the layerStore, that 
is where the 'record' function argument is coming from.
Here is what I would write for the code above:
var container_1 = new GeoExt.tree.LayerContainer({ //group1
    text:'First thematic group',
    layerStore: mapPanel.layers,
    loader:{
          filter:function(record){ return (record.data.layer.metadata.group 
== 'grupo1') }
})

You can see that I simply changed the loader configuration to something 
which will actually filter your layers into the appropriate group for that 
container. The filter function is called for each record in the layerStore 
and if the function returns true, then a node is created for that layer in 
that LayerContainer node.

Hope that helps
Matt Priour
Kestrel Computer Consulting 



More information about the Users mailing list