[Users] Load combo, FeatureStore and filter values

Matt Priour mpriour at kestrelcomputer.com
Thu Nov 3 19:59:36 CET 2011


You would really need to put up a more complete example or a link to an accessible version of the application, or at least a minimal example if the below information doesn’t help

Look at the documentation and examples on ExtJS combo box and the store config option.

First, you want to make sure that you are running ‘collect’ only after the feature store is finished loading.
Second, when you use an array for the ‘store’ configuration option, you do NOT include the ‘displayField’ & ‘valueField’ options. The combo auto-creates a real store from the array and maps the correct field name to the display & value options.

Matt Priour

From: Jorge Lopez 
Sent: Thursday, November 03, 2011 6:52 AM
To: Users at geoext.org 
Subject: Re: [Users] Load combo, FeatureStore and filter values

Thanks Matt for your advice.  

Anyway I didn`t succeed it. As you comment, first I should create an array by using 'collect' method on combo's store. I got it by using an easy example of an arraystore (static) but in my example, with data provided by an web service, when I use collect method like this: 


var combo1=new Ext.form.ComboBox({  
fieldLabel:'Filtro Pais',  
name:'cmb-P',  
forceSelection: true,  
store: store2.collect('COUNTRY'), //store2 is my combo's store 
mode: 'local', 
emptyText:'Select a country',  
triggerAction: 'all',
//allQuery: 'DISTINCT',
editable:false,  
displayField:'COUNTRY',  
valueField: 'COUNTRY'
});  

Nothing is appeared. I think that store is not loaded, so nothing can happen but why I got it if collect is not used?

I can figure out what is happening.

Jorge


On Wed, Nov 2, 2011 at 3:38 PM, Matt Priour <mpriour at kestrelcomputer.com> wrote:

  You’re going to want to use an ArrayStore for that “COUNTRY” combo box, not the feature store.
  If you use the feature store and filter unique countries, you will also be filtering the grid.
  Provide the array returned by the ‘collect’ method (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-collect) on the feature store to the ArrayStore’s loadData function.
  Put a listener on the combo box for the ‘select’ event that uses the selected value to filter the feature store is you want to limit feature records by that value.
  If you are just looking to do linked combos, and not do any filtering or only filter after the user has made a series selections from linked combos, then you should have the ‘select’ listener for the first combo box ‘query’ (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-query) the feature store and either directly use the returned collection in the linked child combo box(es) or further process the collection to unique values for a simple array store backed combo box

  Matt Priour


  From: Jorge Lopez 
  Sent: Wednesday, November 02, 2011 5:22 AM
  To: users at geoext.org 
  Subject: [Users] Load combo, FeatureStore and filter values

  Hello everyone: 



  I am driving mad with this problem. I am doing a web application with OpenLayers, ExtJs and GeoExt and the simple fact to load values in a combo have become hard. 

  Step1: I have defined a featurestore that stores the records from a layer in Geoserver. No problem to load these items in a GeoExt gridPanel. This store has been generated with this code:



  ----

  store = new GeoExt.data.FeatureStore({

                          layer: wfslayer,

                          fields: [

                               {name: 'PLANT', type: 'string'},

                               {name: ‘COUNTRY’, type: ‘string’},

                              {name: ‘STATUS', type: 'string'},

                              {name: 'long', type: 'float'},                                                                  

                              {name: 'lat', type: 'float'},

                          ],

                              proxy: new GeoExt.data.ProtocolProxy({

                                      protocol: new OpenLayers.Protocol.WFS({

                                   //version: "1.0.0",

                                                 srsName: 'EPSG:900913', 

                                               url: "http://localhost:8080/geoserver/wfs",

                                               featureNS: 'http://localhost:8080/wfs',

                                                 featurePrefix: nomPrefix,

                                                 featureType: nomLayer,

                                                 geometryName: nomGeometry,

                                                 schema: http://localhost:8080/geoserver/wfs?service=WFS&request=DescribeFeatureType&typename=lonlat22"

                                                                                    })

                                                             }),        

                                                 autoLoad: true

                                     });

  --



  This store has records with fields (COUNTRY) that contains repeated values and I would like to filter that store by this field: COUNTRY. For that, I have created a ComboBox and I am trying to show only “no repeated” values but no success. 



  var combo1=new Ext.form.ComboBox({  

                                                 fieldLabel:'Filtro Pais',  

                                                 name:'cmb-P',  

                                                 forceSelection: true,  

                                                 store: store,   

                                                 emptyText:'Escoge un país',  

                                                 triggerAction: 'all',  

                                                 //allQuery: 'DISTINCT',

                                                 editable:false,  

                                                 displayField:'COUNTRY',  

                                                 valueField: 'COUNTRY'  

                                     });  

  This combo shows a list of all (repeated) values from store. This a question of ExtJS forum but I would appreciate if anyone knew how to filter it out. 



  Once a country is selected from combo, I would like to be shown the STATUS associated to that selected COUNTRY. This is a question of anidated combos but I don’t know how to ‘featurefilter’ config tag would be entered in this problem. 



  Any ideas? 



  Thanks in advanced



  Jorge


------------------------------------------------------------------------------
  _______________________________________________
  Users mailing list
  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111103/b7ebf398/attachment-0001.htm 


More information about the Users mailing list