[Users] gx_layercontainer filter:
Andreas Hocevar
ahocevar at opengeo.org
Thu Jan 28 21:03:42 CET 2010
Hi,
the problem is here:
var treeConfig = new OpenLayers.Format.JSON().write({...});
...
children: Ext.decode(treeConfig)
This way you prevent all executable code (which the function definitely
is) from ending up in the config.
Instead, do
var treeConfig = {...}
...
children: treeConfig
The reason for this json de/encoding in the example is to allow the user
to play around with configs.
Regards,
Andreas.
Brian Marble wrote:
> Andreas,
>
> I have been using 0.6.
>
> I just checked out the latest SVN at http://svn.geoext.org/core/trunk/geoext
>
>
> I tried a couple of different filters but no change.
>
> Any other ideas?
>
> Thanks,
> Brian
>
>
>> -----Original Message-----
>> From: Andreas Hocevar [mailto:ahocevar at opengeo.org]
>> Sent: Thursday, January 28, 2010 10:22 AM
>> To: Brian Marble
>> Cc: users at geoext.org
>> Subject: Re: [Users] gx_layercontainer filter:
>>
>> Hey-
>>
>> your code should work with a current trunk version of GeoExt, but not
>> with GeoExt 0.6. Which version are you using?
>>
>> Regards,
>> Andreas.
>>
>> Brian Marble wrote:
>>> Hey,
>>>
>>> I am trying to filter a gx_layercontainer (see below). No matter what
>> I do
>>> all of my map.layers show in this branch of the tree. I want to have
>> more
>>> control over the contents of all branches of the tree. It looks like
>> the
>>> filter function just needs to be overridden on my part but I am
>> unable to
>>> make it work as below.
>>>
>>> My test code below is taken from
>>> http://dev.geoext.org/trunk/geoext/examples/tree.html
>>>
>>> Can anyone point out my oversights?
>>>
>>> Thanks,
>>> Brian
>>>
>>> ar options = {
>>> projection: new OpenLayers.Projection("EPSG:900913"),
>>> displayProjection: new OpenLayers.Projection("EPSG:4326"),
>>> theme: null,
>>> units: "m",
>>> maxResolution: 156543.0339,
>>> maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>>> 20037508.34, 20037508.34)
>>> // allOverlays: true
>>> };
>>>
>>> map = new OpenLayers.Map('mapContainer', options);
>>>
>>> var treeConfig = new OpenLayers.Format.JSON().write([{
>>> nodeType: "gx_baselayercontainer",
>>> text: "Base Layers"
>>> }, {
>>> nodeType: "gx_overlaylayercontainer",
>>> text: "Over Layers",
>>> expanded: false,
>>> loader: {
>>> }
>>> }, {
>>> nodeType: "gx_layercontainer",
>>> text: "Special Layers",
>>> expanded: false,
>>> loader: {
>>> filter: function(record) {
>>> var layer = record.get("layer");
>>> // return (!layer.isBaseLayer && layer.name == "2000
>>> Census - Population (TC)");
>>> return !layer.isBaseLayer;
>>> }
>>>
>>> }
>>> }
>>> ], true);
>>>
>>> var tree = new Ext.tree.TreePanel({
>>> border: true,
>>> region: "west",
>>> title: "Layers",
>>> width: 200,
>>> split: true,
>>> collapsible: true,
>>> collapseMode: "mini",
>>> autoScroll: true,
>>> loader: new Ext.tree.TreeLoader({
>>> applyLoader: false
>>> }),
>>>
>>> root: {
>>> nodeType: "async",
>>> children: Ext.decode(treeConfig)
>>> },
>>> listeners: {
>>> "insert": registerRadio,
>>> "append": registerRadio
>>> },
>>> rootVisible: false,
>>> lines: false,
>>> bbar: [{
>>> text: "Show/Edit Tree Config",
>>> handler: function() {
>>> treeConfigWin.show();
>>> Ext.getCmp("treeconfig").setValue(treeConfig);
>>> }
>>> }]
>>> });
>>>
>>> ______________________________________________
>>> Brian Marble
>>> LandEZ Corp.
>>> W - 435 787 9003
>>> C - 435 881 3117
>>> F - 435 787 9004
>>> BrianMarble at LandEZ.com
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at geoext.org
>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list