2 Attachment(s)
[4.1b1] Bug with Implicit Model / Store / MixedCollection / Proxy
REQUIRED INFORMATIONExt version tested:Browser versions tested against:DOCTYPE tested against:Description:- In 1 store the getKey function applied to the data's MixedCollection object is returning an id of 1 no matter what the actual id is. This in turn is causing MixedCollection's add method to overwrite the models and the result is only the last model is added to the data collection.
- During the loop in addAll in the AbstractMixedCollection class it calls add, in the 'add' method I put the following console.log in
Code:
if (arguments.length == 1) { myObj = myKey;
console.log('myKey', myObj, myObj.id, myObj.internalId, me.getKey(myObj));
myKey = me.getKey(myObj);
}
- See the screen shots and output below for the results.
- As a side note replacing 4.1 with 4.0.7 fixes this issue. So it's a change that happened sometime between 4.0.7 and 4.1
Steps to reproduce the problem:The result that was expected:- the getKey method of MixedCollection returns the appropriate id.
The result that occurs instead:- the getKey method always returns 1
Test Case:
Working Store.
Code:
// Store definition
Ext.define('Foo.store.user.UserStore', {
extend:'Ext.data.Store',
autoLoad:false,
fields:[
{name:'userId', type:'int'},
{name:'firstName', type:'string'},
{name:'lastName', type:'string'},
{name:'username', type:'string'},
{name:'disabled', type:'bool'}
],
proxy:{
type:'direct',
reader:{
idProperty:'userId',
type:'json',
root:'data'
},
api:{
read:Foo.Direct.User.readUsers
}
}
});
Broken Store.
Code:
Ext.define('Foo.store.project.ProjectStore', {
extend:'Ext.data.Store',
autoLoad:false,
fields:[
{name:'projectId', type:'int'},
{name:'name', type:'string'},
{name:'subscriptionType', type:'string'},
{name:'projectStatus', type:'string'}
],
proxy:{
type:'direct',
reader:{
idProperty:'projectId',
type:'json',
root:'data'
},
api:{
read:Foo.Direct.Project.readProjects
}
}
});
Data returned by server
Code:
//Project
[
{"projectId":5,"name":"Fallout Town","subscriptionType":"","projectStatus":"Closed"},
{"projectId":1,"name":"Science Lab","subscriptionType":"","projectStatus":"Active"},
{"projectId":2,"name":"Underground City","subscriptionType":"Professional Unlimited","projectStatus":"Active"}
]
//User
[
{"userId":1,"firstName":"Admin","lastName":"Lasso","username":"devteam","disabled":0},
{"userId":2,"firstName":"Alice","lastName":"T-Virus","username":"alice","disabled":1},
{"userId":3,"firstName":"Jill","lastName":"Valentine","username":"jillv","disabled":0},
{"userId":4,"firstName":"yetestse","lastName":"testestes","username":"testestse","disabled":0}
]
Possible fix:Additional CSS used:Operating System: