[Users] GeoExt.data.FeatureRecord.create and GeoExt.data.FeatureStore

James McManus jmpmcmanus at gmail.com
Fri Oct 2 02:01:07 CEST 2009


Hi - I'm working with a map app that is using GeoExt and MapFish. In this
app you can click or draw boxes on features in the the map, and data values
for the features are then displayed in a Ext.grid.GridPanel. It's your basic
example.  It uses object created from mapfish.Protocol.MapFish.create,
GeoExt.data.FeatureStore, mapfish.widgets.data.SearchStoreMediator, and
mapfish.Searcher.Map. It also uses Ext.grid.GridPanel in a Ext.Viewport.

In the initial app, which works, a feature store is created using the
following method:

Store = new GeoExt.data.FeatureStore({
          fields: [
             {name: 'stfid', type: 'string'},
             {name: 'ch_0209_r_tax_val', type: 'float'}
          ]
});

However, I want to be able to change values of "name" in Store, using the
method:

var record = Store.getAt(0);
record.set("name", "stfid");

I found that I could not do this using a Store created by the above method.
However, I found the recored.set method worked if Store was created using
this method:

        var Record = GeoExt.data.FeatureRecord.create([
          { name : "name", mapping : "name" },
          { name : "type", mapping : "type" }
        ]);

        var Store = new GeoExt.data.FeatureStore({
          fields: ['name', 'type'],
        });

        var Data = [
          { name : "stfid", type : "string" },
          { name : "ch_0209_r_tax_val", type : "float" }
        ];

        for (var i = 0; i < Data.length; i++) {
          Store.add(
            new Record({
              name : Data[i].name, type : Data[i].type
            })
          );

Unfortunately, now when I click on the map, no data values are displayed in
the GridPanel. The data is in firebug Console Response. When I use the first
method to create Store, I can find the values under:

Store.data.items.0.data                  Object feature=Object fid=25
stfid=37...
         ch_0209_r_tax_val                108.31

However, these values do not exist when I use the second method to create
Store.  How does the second method change the structure of Store to cause
this problem?

Thanks
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20091001/f5174a46/attachment-0001.htm 


More information about the Users mailing list