[Users] Modify record in a store

James McManus jmpmcmanus at gmail.com
Thu Oct 1 05:36:09 CEST 2009


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 <jmpmcmanus at gmail.com>
> *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/fed222ed/attachment.htm 


More information about the Users mailing list