PDA

View Full Version : [CLOSED] [4.2] getCount() returns wrong count on Memory store



kerbo
9 Apr 2013, 5:40 PM
Using this code on jsFiddle:



Ext.onReady(function(){

Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [
{name:'id',type:'int'},
'name',
'email_id',
'emp_num',
'title'
]
});
var dsPersons = new Ext.data.Store({
model: 'Person',
proxy: {
type: 'memory'
}
});

var person = {
id : 0,
name: '',
email_id: '',
title: '',
emp_num: ''
};
dsPersons.add(person);

dsPersons.add(person);

dsPersons.add(person);

alert(dsPersons.getCount());

});


In 4.2, getCount is 1 (incorrect)

In 4.1.1, getCount is 3 (correct)

mitchellsimoens
9 Apr 2013, 5:46 PM
This is because you have id collisions. Each record must have it's own unique id.

kerbo
9 Apr 2013, 5:53 PM
Yes, I see now in the docs that idProperty must be set to null in order to have a duplicate value in the id field.

Problem, I guess is this code works in 4.1.1 and now it doesn't.