After thinking about your suggestions, and looking at more documentation, I found it works if a define a record first. For example:<br><br> var Record = GeoExt.data.FeatureRecord.create([<br> { name : "name", mapping : "name" },<br>
{ name : "type", mapping : "type" }<br> ]);<br><br> Store = new GeoExt.data.FeatureStore({<br> fields: ['name', 'type'],<br> });<br><br> var Data = [<br>
{ name : "stfid", type : "string" },<br> { name : "ch_0209_r_tax_val", type : "float" }<br> ];<br><br> for (var i = 0; i < Data.length; i++) {<br>
Store.add(<br> new Record({<br> name : Data[i].name, type : Data[i].type<br> })<br> );<br> }<br><br> var record = Store.getAt(0);<br> record.set("name", "ID");<br>
<br>This changes stfid to ID in the DOM, under store.data.items.0.<br><br>Using:<br><br>var record = store.getAt(0);<br>
record.set("stfid", "ID");<br><br>does not work. <br><br>Jim<br><br><div class="gmail_quote">On Thu, Oct 1, 2009 at 12:41 AM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi<br>
<div class="im"><br>
On Thursday, October 1, 2009, James McManus <<a href="mailto:jmpmcmanus@gmail.com">jmpmcmanus@gmail.com</a>> wrote:<br>
> The id is an artifact of my experimentation. I should of left it out.<br>
> A cleaner version would be:<br>
><br>
> var Store = new GeoExt.data.FeatureStore({<br>
> fields: [<br>
> {name: 'stfid', type: 'string'},<br>
> {name: 'ch_0209_r_tax_val', type: 'float'}<br>
> ]<br>
> });<br>
<br>
</div>The array passed to the "field" option represents the data schema of<br>
the store, not the actual data. Use the "data" option to pass actual<br>
data.<br>
<div class="im"><br>
> var record = Store.getAt(0);<br>
> record.set("name","ID");<br>
<br>
</div>if you want to change the value of the first record's stfid field you'll do<br>
<div class="im"><br>
var record = store.getAt(0);<br>
</div>record.set("stfid", "ID");<br>
<br>
Hope this helps,<br>
<div class="im"><br>
><br>
> 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.<br>
><br>
> 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:<br>
><br>
> var Store = new. Ext.data.Store({<br>
> [{name: 'stfid', type: 'string'},<br>
> {name: 'ch_0209_r_tax_val']<br>
> }<br>
><br>
> 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?<br>
><br>
> In any case I'm unsure how to work with it.<br>
><br>
> Thanks<br>
> Jim<br>
><br>
</div><div class="im">> On Wed, Sep 30, 2009 at 9:50 PM, Matt Priour <<a href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</a> <javascript:_e({}, 'cvml', '<a href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</a>');>> wrote:<br>
><br>
><br>
><br>
><br>
><br>
> You've got a whole lot of things going wrong<br>
> there.<br>
> You should really look into the ExtJS docs<br>
> regarding DataStores.<br>
> <a href="http://www.extjs.com/deploy/ext-2.2/docs/?class=Ext.data.JsonStore" target="_blank">http://www.extjs.com/deploy/ext-2.2/docs/?class=Ext.data.JsonStore</a><br>
><br>
> id is a property of the store, not the field. id<br>
> refers to the field whose value will be used as the record's id and used in<br>
> functions like getById.<br>
> the function record.set modifies the value found in<br>
> the field indicated in the first parameter and changes it to the value indicated<br>
> in the second parameter.<br>
> Your use of it fails because you don't have a field<br>
> named "name" .<br>
> If you did it would change the value in that field<br>
> in the record to the string "id"<br>
><br>
> Hope that helps at least point you in the right<br>
> direction to begin accomplishing what you are wanting to do.<br>
><br>
> Matt Priour<br>
> Kestrel Computer Consulting<br>
><br>
><br>
><br>
><br>
</div>> From: James McManus <javascript:_e({}, 'cvml', '<a href="mailto:jmpmcmanus@gmail.com">jmpmcmanus@gmail.com</a>');><br>
<div class="im">> Sent: Wednesday, September 30, 2009 6:08 PM<br>
</div>> To: <a href="mailto:users@geoext.org">users@geoext.org</a> <javascript:_e({}, 'cvml', '<a href="mailto:users@geoext.org">users@geoext.org</a>');><br>
<div><div></div><div class="h5">> Subject: [Users] Modify record in a store<br>
><br>
><br>
> Hi - I would like to<br>
> modify a record in a store, I created using GeoExt.data.FeatureStore. The actual<br>
> store looks like:<br>
><br>
> var store =<br>
> new<br>
> GeoExt.data.FeatureStore({<br>
> fields:<br>
> [<br>
> {id: new Date().getTime(), name: 'stfid', type:<br>
> 'string'},<br>
> {id: new Date().getTime(), name: 'ch_0209_r_tax_val', type:<br>
> 'float'}<br>
> ]<br>
> });<br>
><br>
> I thought I could<br>
> modify it by doing the following:<br>
><br>
> var record =<br>
> store.getAt(0);<br>
> record.set("name", "id");<br>
><br>
> which would change stfid to<br>
> id. But that did not work. I think it is because I'm not dealing with the<br>
> presents of "fields". I've tried a variety of things without<br>
> success. Is there a simple way of doing this?<br>
><br>
> Thanks<br>
> Jim<br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Users mailing<br>
> list<br>
</div></div>> <a href="mailto:Users@geoext.org">Users@geoext.org</a> <javascript:_e({}, 'cvml', '<a href="mailto:Users@geoext.org">Users@geoext.org</a>');><br>
<div class="im">> <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>
</div>--<br>
Eric Lemoine<br>
<br>
Camptocamp France SAS<br>
Savoie Technolac, BP 352<br>
73377 Le Bourget du Lac, Cedex<br>
<br>
Tel : 00 33 4 79 44 44 96<br>
Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
</blockquote></div><br>