Open GoogleCodeExporter opened 9 years ago
i investigate it and found this out:
i you use the GWTProxy then you can also use a custom reader / ArrayReader. if
you
specify a id column then this column is used. otherwise the autoid code is used
for
the id. here are the codesnippets which are used for the auto id:
Ext.data.Record = function(data, id){
this.id = (id || id === 0) ? id : ++Ext.data.Record.AUTO_ID;
this.data = data;
};
Ext.data.Record.AUTO_ID = 1000;
this record create is caleld from this (look at the marked lines):
Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
readRecords : function(o){
var sid = this.meta ? this.meta.id : null; // <-------------------
var recordType = this.recordType, fields = recordType.prototype.fields;
var records = [];
var root = o;
for(var i = 0; i < root.length; i++){
var n = root[i];
var values = {};
var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ?
n[sid] : null); // <-------------------
for(var j = 0, jlen = fields.length; j < jlen; j++){
var f = fields.items[j];
var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
var v = n[k] !== undefined ? n[k] : f.defaultValue;
v = f.convert(v, n);
values[f.name] = v;
}
var record = new recordType(values, id); // <-------------------
record.json = n;
records[records.length] = record;
}
return {
records : records,
totalRecords : records.length
};
}
});
Original comment by nietz...@gmail.com
on 1 Apr 2009 at 9:23
but note this pitfall:
if you load your records with this id but later you add new records with
myRecordDef.createRecord( Object[] rowData )
then you dont have a id and it uses the autoid starting with 1000. this then can
mixed with the "normal" id previously readed.
solution:
use myRecordDef.createRecord( String id , Object[] rowData ) with your own id.
Original comment by nietz...@gmail.com
on 1 Apr 2009 at 9:31
to avoid the auto id for your record creation.
use ArrayReader(int id, RecordDef recordDef) to specify a column index with
your own id.
Original comment by nietz...@gmail.com
on 1 Apr 2009 at 9:33
Original issue reported on code.google.com by
jasonzha...@gmail.com
on 17 Oct 2008 at 3:51