ExtJs 6.2
var store = Ext.create("Ext.data.Store");
var dep = {dd:11};
store.add({dd:11});
store.add(dep);
store.add(dep);
store.add(dep);
store.add(dep);
store.add(dep);
store.add(dep);
store.add(dep);
store.add({dd:11});
console.log("Count:" + store.count());
Count:3
A variable object is added only once. Why?????
The reason behind this is that store.add
is not pure function meaning it changes dep
so after first add dep
no longer holds reference to a simple javascript object but instead it is a reference to added model. After that you are trying to add model that is already in a store so it is omitting it
You can verify this by doing console.log
of a def
variable after first add
Wokaround:
store.add(Ext.clone(dep));