[Users] Modify record in a store

Matt Priour mpriour at kestrelcomputer.com
Thu Oct 1 06:21:32 CEST 2009


Yes, GeoExt.data.FeatureStore inherits fields and all other configuration attributes, methods, properties, & events of Ext.data.Store, Ext.data.Reader, and  Ext.data.MemoryProxy as well as GeoExt.data.FeatureReader.
The reason "record is undefined" is that the store doesn't yet contain any data. So how could it return a record if none exist yet? Also FeatureStores are usually attached to a map layer via the "layer" configuaration attribute. 
This layer property is what allows the Feature Store to automatically include features from a layer.

Matt Priour
Kestrel Computer Consulting

From: James McManus 
Sent: Wednesday, September 30, 2009 10:36 PM
To: Matt Priour 
Cc: users at geoext.org 
Subject: Re: [Users] Modify record in a store


The id is an artifact of my experimentation. I should of left it out.
A cleaner version would be:

        var Store = new GeoExt.data.FeatureStore({
          fields: [
             {name: 'stfid', type: 'string'},
             {name: 'ch_0209_r_tax_val', type: 'float'}
          ]
        });
        var record = Store.getAt(0);
        record.set("name","ID");

in which I get the error message "record is undefined".  That may mean that Store.getAt(0) is not working. Although I have not found an error.

I've been looking at Ext JS documentation.  That is where I got the idea to use record.set to modify a record. However, the examples I've seen look like:

var Store = new. Ext.data.Store({
    [{name: 'stfid', type: 'string'},
     {name: 'ch_0209_r_tax_val']
}

There is no fields, like I'm using in GeoExt.data.FeatureStore. The API for FeatureStore does not list fields as a config option. Is it inherited from Ext.data.Store?

In any case I'm unsure how to work with it. 

Thanks
Jim
         

On Wed, Sep 30, 2009 at 9:50 PM, Matt Priour <mpriour at kestrelcomputer.com> wrote:

  You've got a whole lot of things going wrong there.
  You should really look into the ExtJS docs regarding DataStores.
  http://www.extjs.com/deploy/ext-2.2/docs/?class=Ext.data.JsonStore

  id is a property of the store, not the field. id refers to the field whose value will be used as the record's id and used in functions like getById.
  the function record.set modifies the value found in the field indicated in the first parameter and changes it to the value indicated in the second parameter.
  Your use of it fails because you don't have a field named "name" .
  If you did it would change the value in that field in the record to the string "id"

  Hope that helps at least point you in the right direction to begin accomplishing what you are wanting to do.

  Matt Priour
  Kestrel Computer Consulting


  From: James McManus 
  Sent: Wednesday, September 30, 2009 6:08 PM
  To: users at geoext.org 
  Subject: [Users] Modify record in a store


  Hi - I would like to modify a record in a store, I created using GeoExt.data.FeatureStore. The actual store looks like:

          var store = new GeoExt.data.FeatureStore({
            fields: [
               {id: new Date().getTime(), name: 'stfid', type: 'string'},
               {id: new Date().getTime(), name: 'ch_0209_r_tax_val', type: 'float'}
            ]
          });

  I thought I could modify it by doing the following:

  var record = store.getAt(0);
  record.set("name", "id");

  which would change stfid to id. But that did not work. I think it is because I'm not dealing with the presents of "fields".  I've tried a variety of things without success.  Is there a simple way of doing this?

  Thanks
  Jim




------------------------------------------------------------------------------


  _______________________________________________
  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/20090930/75982c02/attachment-0001.htm 


More information about the Users mailing list