PDA

View Full Version : i guess i found a bug when using Composite Key...



Rothariger
16 Dec 2009, 12:57 PM
Hello...

i will try to explain what i do and what is the result because i cant put example code, because the page is created by a couple of .js files.

well i create a store and set it a composite key, nothing crazy here...



new Ext.data.Store({
proxy : new Ext.data.HttpProxy({url: 'Handler/POSCollectionsHandler.ashx',
method :'POST', timeout: '25000'}),
remoteSort : true,
fields: {xxx},
idProperty: 'QuestionId + "|" + obj.ItemId'
baseParams : {action: action },
reader : new Ext.data.JsonReader({
totalProperty : "totalCount",
idProperty : xId,
root : "elements"
}, record)
});

well this code was working very fine in 2.0...


no i will detail what i think its wrong... debugging the ext-all i found this piece of code...


extractData : function(root, returnRecords) {
var rs = undefined;
if (this.isData(root)) {
root = [root];
}
if (Ext.isArray(root)) {
var f = this.recordType.prototype.fields,
fi = f.items,
fl = f.length,
rs = [];
if (returnRecords === true) {
var Record = this.recordType;
for (var i = 0; i < root.length; i++) {
var n = root[i];
var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
record.json = n;
rs.push(record);
}
}
else {
for (var i = 0; i < root.length; i++) {
rs.push(this.extractValues(root[i], fi, fl));
}
}
}
return rs;
}


i bolded what i think its wrong...

in that isData the calls the .getId


return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;


but the thing is that the array is being passed, this manner the composite key makes the trick here...
this.getId(data) instead of returning null, returns undefinded|undefined...

and then the code continues and executes


root = [root];


and i have a array in an array, and my grid doesnt fills like before...
i dont know if i was very clear...

can someone give me a lead to fix this???

thanks!!!