here is my code
Ext.define('MyModel', {
extend: 'Ext.data.Model',
config: {
fields: ['name', {
name: 'twitter',
type: 'string'
}]
}
});
Ext.define('Fiddle.MyStore', {
extend: 'Ext.data.Store',
config: {
model: 'MyModel',
listeners: {
}
},
addrecords: function(store, records, eOpts) {
console.log('new recorded have been added.');
console.log('new recorded number = ' + store.getCount());
}
});
Ext.application({
name: 'Fiddle',
launch: function() {
Ext.Msg.alert('Fiddle', 'Welcome to Sencha Fiddle!');
var mystore = Ext.create('Ext.data.Store', {
data: [{
name: 'Mitchell Simoens',
twitter: 'SenchaMitch'
}, {
name: 'Jay Garcia',
twitter: 'ModusJeasus'
}, {
name: 'Anthony De Moss',
twitter: 'ademoss1'
}]
});
mystore.add({
name: "winston fan",
twitter: 'WFC'
});
//console.log('mystore has ' + mystore.getCount());
}
});
and here is the sencha fiddle : https://fiddle.sencha.com/#fiddle/6d1
I know I can use mystore.on() to bind the event, but it's hard to do it in my case. So I'd like to put the addrecords into the config of the store. But no matter where I put the code
addrecords: function(store, records, eOpts) {
console.log('new recorded have been added.');
console.log('new recorded number = ' + store.getCount());
}
either in listeners under config section, or directly under the store, the addrecords event doesn't get triggered. It is only triggered when I use mystore.on('addrecords', function() {}); .
Can anyone tell me how to put the event in the config of the store?
thank you.