View Full Version : [SOLVED] datachanged event firing twice?

19 Jul 2010, 6:14 AM
I have a simple store and have a listener to the 'datachanged' event. I've noticed however that this is getting fired twice which could mess up what I'm planning on doing.

new Ext.data.JsonStore({
data: [{
name: 'Dept A'
name: 'Dept B'
fields: ['name'],
listeners : {
datachanged : function(store) {
if (store.getCount() === 0) {
//no recs
} else {

I have the function doAdd just alert the rec.get("name") and it alerts in this order

Dept A
Dept B
Dept A
Dept B

If I remove the data config and use loadData it still happens.

Solved by listening to the add and remove events instead of datachanged. Still do not know why it fires twice but oh well.

2 Sep 2010, 11:06 AM
I have the same problem: datachanged fires twice! why is this like this?
your workaround is nothing for me...
is there another listener for this purpose? I'd like update the store by reading it and need an event when it's finished...
thanks for any tips.

2 Sep 2010, 11:10 AM
datachanged fires when the data is changed. Whether it's add, removed, sorted, anything. If you have a sorting, it will fire twice. There is a 'filterOnLoad' config option and if set to false it then the datachanged event will only fire once.