[Users] variables in filter of LayerContainer loader
geographika
geographika at gmail.com
Fri Feb 11 11:53:35 CET 2011
Hi,
Where are your themes and theme variables defined? They will need to be
in the scope of the filter function to work correctly.
Try putting a debugger; statement in to see exactly what is in these
variables (I'd imagine undefined at the moment).
filter: function(record){
debugger;
return (record.get("layer").options.themeId == themes[theme].id);
}
Regards,
Seth
--
web:http://geographika.co.uk
twitter: @geographika
On 11/02/2011 11:32, Frans Knibbe wrote:
> Hello!
>
> I am trying to create several GeoExt.tree.LayerContainer nodes in my
> layer tree. I want to group layers by a custom attribute (themes) that I
> have added to the OpenLayers layer definition. Let's call this attribute
> 'themeId'. It could have values like 'vegetation', 'water', 'roads',
> etc.. What I want to do is loop though the themes and create
> .LayerContainers for matching layers. I am doing this by means of a
> filter of the GeoExt.tree.LayerLoader, which looks like this:
>
> filter: function(record){
> return (record.get("layer").options.themeId == themes[theme].id);
> }
>
> My problem is that the filter does not work :-). This seems to be caused
> by the variable holding the theme ID ( themes[theme].id in the example
> above) being unknown at them time the filter function is executed. If I
> exchange the variable with a string everything works fine, like this:
>
> filter: function(record){
> return (record.get("layer").options.themeId == 'vegetation');
> }
>
> So my question is: Can I somehow get the variable to have the right
> value at the time the filter function is executed? Or is there another
> way of dynamically building LayerContainers I could try?
>
> Thanks!
> Frans
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110211/2a85fcbb/attachment.htm
More information about the Users
mailing list