[Users] Synchronising LayerTree Node w/ checkbox and Map with aGrid Panel

Daniel Behr daniel.behr at hzg.de
Fri Feb 25 16:48:08 CET 2011


I first tried to use the GeoExt GridStore.featureFilter (see below), but 
this didnt work.

To fix this was actually so easy I didnt see it...

I now use the Ext gridStore.filter method like this:

wfsPlatform.events.register('visibilitychanged', this, function(){
     if (wfsPlatform.visibility) {
	gridStore.clearFilter();
     } else {
	gridStore.filter('TITLE', '_', false, true); // always false
     }
});

just this, no listener on the treePanel for this event and now it works 
fine !

thanks again Matt for pointing me to the filters.
Dan



Am 23.02.2011 16:35, schrieb Daniel Behr:
> thanks Matt,
>
> I had to get the Filter working first, but now I'm stuck again.
>
> this false-Filter works:
>
> featureFilter = new OpenLayers.Filter.Logical({
>       type: OpenLayers.Filter.Logical.NOT,
>       filters: [new OpenLayers.Filter.Comparison({
> 	type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
> 	property: "TITLE",
> 	value: "_"
>       })]
> });
>
> and instead of attaching the listener to the treePanel, I registered the
> event with the layer:
>
> wfsPlatform.events.register('visibilitychanged', this, function() {
> 	if (wfsPlatform.visibility) {
> 	    gridStore.featureFilter = featureFilter
> 	} else {
> 	    gridStore.featureFilter = null
> 	    // (...?...)
> 	}
> });
>
> normally I would have to set the featureFilter=null when visibility is
> true, but that doesnt work. And as with my previous solution, there is
> no sync. after checking and unchecking the layer, the grid still stays
> the same.
>
> Do I have to add something to the if/else statement, or maybe I have to
> register the event also (or only) with the gridPanel listener?
>
> thanks in advance for any further hint
> Dan
>
>
> Am 17.02.2011 15:29, schrieb Matt Priour:
>> The issue is that you are looking at 2 totally different things.
>> The checkbox for the layer on the tree controls the WFS layer's
>> visibility on the map.
>> This merely makes the div which hosts the vector features visible or not
>> once the features have initially loaded.
>> The grid is attached to a FeatureStore synced with the WFS Layer's features.
>> When you clear the grid then you are affecting the store and if you have
>> the sync direction from layer-to-store only then removing records from
>> the store doesn't remove them from the layer.
>> If you really want the features to clear from the grid and then return
>> in response to the checkbox, then what you should do is apply an always
>> false filter to the feature store when you uncheck the layer and remove
>> the filter when you check the layer. (I would actually attach that to
>> the layer's visibilitychanged event and not the checkbox's events)
>> Matt Priour
>> Kestrel Computer Consulting
>>
>> *From:* Daniel Behr<mailto:daniel.behr at hzg.de>
>> *Sent:* Thursday, February 17, 2011 4:24 AM
>> *To:* users at geoext.org<mailto:users at geoext.org>
>> *Subject:* [Users] Synchronising LayerTree Node w/ checkbox and Map with
>> aGrid Panel
>>
>> Hi,
>> rather simple question, I guess, but I cant figure it out.
>>
>> I have a mapPanel and a treePanel, added a WFS Layer with a checkbox to
>> the tree and when the box is checked the features are loaded and I see a
>> list of features in a grid panel below.
>> this works as expected until the box is unchecked. The grid panel is not
>> cleared.
>>
>> adding a listener to the tree config clears the gridpanel but after
>> checking the box again the map is updated but the grid stays empty.
>>
>> listeners: {
>> 'checkchange': function(node, checked) {
>> if (checked === false) {
>> // gridPanel.toggleCollapse()
>> gridPanel.removeAll();
>> gridPanel.update()
>> }
>> }
>> }
>>
>> does anyone know of an example where I can look at the code or maybe
>> someone can give me a hint what I am missing here?
>> thanks
>> Dan
>> _______________________________________________
>> Users mailing list
>> Users at geoext.org<mailto:Users at geoext.org>
>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list