Hi, I've found the solution:<div>here follows my code that is the filter on the store:</div><div><br></div><div><div><i>map.events.register('zoomend',this, function(){</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                </i></span><i>var extent = map.getExtent();</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                </i></span><i>featureStore.filterBy(function(record){</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                        </i></span><i>return extent.containsLonLat(new OpenLayers.LonLat(record.data.feature.geometry.x,record.data.feature.geometry.y));</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                </i></span><i>});<span class="Apple-tab-span" style="white-space:pre">        </span></i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i>});</i></div>
<div><i><br></i></div><div>Many thanks.</div><br><div class="gmail_quote">2010/11/2 Simone Dalmasso <span dir="ltr"><<a href="mailto:simone.dalmasso@gmail.com">simone.dalmasso@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
With ratio and resFactor I can see a request on each zoom action but the list in my gris is always the same with all objects.<div>Being that my map starts at the full zoom and with all features displayed and I want that zooming in the gird reduce the number of names displayed. I should try to apply the filter only on the featureStore that fills the grid, so to avoid continuous requests to the server. </div>
<div><br></div><div>Thanks for your explanation Andreas, now is more clear.<div><div></div><div class="h5"><br><br><div class="gmail_quote">2010/11/2 Andreas Hocevar <span dir="ltr"><<a href="mailto:ahocevar@opengeo.org" target="_blank">ahocevar@opengeo.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
there is no need to redraw the layer on zoomend. The reason why you don't see changes is because the BBOX strategy won't reload features if you zoom in, and has a buffer so it may be that you can also zoom out once before you see changes.<br>
<br>
If you really want the strategy to reload on every zoom, and load it exactly the features that match the visible match extent, you should configure the strategy with<br>
<br>
ratio: 1,<br>
resFactor: 1<br>
<br>
Regards,<br>
<font color="#888888">Andreas.<br>
</font><div><div></div><div><br>
On Nov 2, 2010, at 15:23 , Simone Dalmasso wrote:<br>
<br>
> Seems that the proxy doesn't have the setFilter method.<br>
> Actually the strategy is an excellent solution, but I need to trigger a reload of the store on zoomend and moovend.<br>
><br>
> To explain I pos my new code:<br>
><br>
> var sites = new OpenLayers.Layer.Vector('Sites',{<br>
> styleMap: styleMap,<br>
> strategies: [/*new OpenLayers.Strategy.Fixed(),*/new OpenLayers.Strategy.BBOX()],<br>
> projection: new OpenLayers.Projection("EPSG:4326"),<br>
> protocol: new OpenLayers.Protocol.WFS({<br>
> version: "1.1.0",<br>
> srsName: "EPSG:4326",<br>
> url: '/geoserver/wfs/',<br>
> featureType: 'name',<br>
> featurePrefix: "prefix"<br>
> })<br>
> });<br>
><br>
> map.events.register('zoomend',this, function(){<br>
> sites.redraw();<br>
> });<br>
><br>
> var featureStore = new GeoExt.data.FeatureStore({<br>
> fields: [<br>
> {name: "name", type: "string"}<br>
> ],<br>
> layer: sites<br>
> });<br>
><br>
> and more...<br>
><br>
> With that I can't see changes in the grid.<br>
><br>
> Thanks a lot for your help.<br>
><br>
> Simone<br>
><br>
> 2010/11/2 Andreas Hocevar <<a href="mailto:ahocevar@opengeo.org" target="_blank">ahocevar@opengeo.org</a>><br>
> Hi,<br>
><br>
> try the following:<br>
><br>
> featureStore.proxy.setFilter(your_new_filter);<br>
> featureStore.reload();<br>
><br>
> 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.<br>
><br>
> Regards,<br>
> Andreas.<br>
><br>
> On Nov 2, 2010, at 14:24 , Simone Dalmasso wrote:<br>
><br>
> > 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.<br>
> > 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.<br>
> > I post some code:<br>
> ><br>
> > var featureStore = new GeoExt.data.FeatureStore({<br>
> > fields: [<br>
> > {name: "name", type: "string"}<br>
> > ],<br>
> > layer: map.getLayersByName('Sites')[0],<br>
> > featureFilter : new OpenLayers.Filter.Spatial({<br>
> > type : OpenLayers.Filter.Spatial.BBOX,<br>
> > value : map.getExtent()<br>
> > });<br>
> > var gridFeature = new Ext.grid.GridPanel({<br>
> > store: featureStore,<br>
> > sm: new GeoExt.grid.FeatureSelectionModel(),<br>
> > cm: new Ext.grid.ColumnModel([{header:'Name',dataIndex: "name",id:'name'}]),<br>
> > autoExpandColumn : 'name'<br>
> > });<br>
> ><br>
> > Then I wrote:<br>
> > map.events.register('zoomend',this, function(){<br>
> > featureStore.reload();<br>
> > });<br>
> ><br>
> > But in this way I get the this.proxy is null error from ext.js<br>
> > I've also tried to re-bind the layer:<br>
> > map.events.register('zoomend',this, function(){<br>
> > featureStore.unbind();<br>
> > featureStore.bind(map.getLayersByName('Sites')[0]);<br>
> > });<br>
> > But I get record is undefined error from ext.js<br>
> ><br>
> > For both I still have all the features displayed in the grid.<br>
> > Maybe I should destroy and recreate the entire gridPanel but is not the right way to do that for me.<br>
> > Can you help me?<br>
> > Thanks<br>
> > --<br>
> > Simone Dalmasso<br>
> > _______________________________________________<br>
> > Users mailing list<br>
> > <a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br>
> > <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
><br>
> --<br>
> Andreas Hocevar<br>
> OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
> Expert service straight from the developers.<br>
><br>
><br>
><br>
><br>
> --<br>
> Simone Dalmasso, Ing.<br>
> ITHACA<br>
> Information Technology for Humanitarian Assistance, Cooperation and Action<br>
> <a href="http://www.ithacaweb.org" target="_blank">www.ithacaweb.org</a><br>
> Via Pier Carlo Boggio 61 - 10138 Torino<br>
> Tel: +39.011.1975.1854<br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br>
> <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Simone Dalmasso, Ing.<br>ITHACA<br>Information Technology for Humanitarian Assistance, Cooperation and Action<br><a href="http://www.ithacaweb.org" target="_blank">www.ithacaweb.org</a><br>
Via Pier Carlo Boggio 61 - 10138 Torino<br>Tel: +39.011.1975.1854<br>
</div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Simone Dalmasso, Ing.<br>ITHACA<br>Information Technology for Humanitarian Assistance, Cooperation and Action<br><a href="http://www.ithacaweb.org">www.ithacaweb.org</a><br>
Via Pier Carlo Boggio 61 - 10138 Torino<br>Tel: +39.011.1975.1854<br>
</div>