[Users] featureStore filter reload

Andreas Hocevar ahocevar at opengeo.org
Tue Nov 2 14:48:34 CET 2010


try the following:


But note that you could also configure your vector layer with your protocol and a BBOX strategy, and bind your featureStore to that layer by configuring the store's layer property. This will make the BBOX strategy take care of requesting features for the correct extent.


On Nov 2, 2010, at 14:24 , Simone Dalmasso wrote:

> Hi list, I have an OL vector layer with a feature store linked. The output of the store is in a grid, so I have the name of the features selectable.
> What I would like to do is to apply a spatial filter (BBOX) on the store to have displayed in the grid only the features that are within the BBOX. The update events for the store should be the 'zoomend' and the 'moveend' events of the map.
> I post some code:
> var featureStore = new GeoExt.data.FeatureStore({
> 	    fields: [
> 	        {name: "name", type: "string"}
> 	    ],
> 	    layer: map.getLayersByName('Sites')[0],
>             featureFilter : new OpenLayers.Filter.Spatial({
> 		type : OpenLayers.Filter.Spatial.BBOX,
> 		value : map.getExtent()
> });
> var gridFeature = new Ext.grid.GridPanel({
> 		store: featureStore,
> 		sm: new GeoExt.grid.FeatureSelectionModel(),
> 		cm: new Ext.grid.ColumnModel([{header:'Name',dataIndex: "name",id:'name'}]),
> 		autoExpandColumn : 'name'
> });
> Then I wrote:
> map.events.register('zoomend',this, function(){
>             featureStore.reload();
> });
> But in this way I get the this.proxy is null error from ext.js
> I've also tried to re-bind the layer:
> map.events.register('zoomend',this, function(){   
>     featureStore.unbind();
>     featureStore.bind(map.getLayersByName('Sites')[0]);
> });
>  But I get record is undefined error from ext.js
> For both I still have all the features displayed in the grid.
> Maybe I should destroy and recreate the entire gridPanel but is not the right way to do that for me.
> Can you help me?
> Thanks
> -- 
> Simone Dalmasso
> _______________________________________________
> 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.

More information about the Users mailing list