Reputation: 10302
I have created class for combobox, which object can be created whenever combobox need in project.
now for every change event of every combo there can be different things to do, so I have not written any code in my combo class for combo change event.
I need something like I can assign code to combo change event when i create it or after creating.
So i write below code .
Ext.getCmp('combo1').on('change', Ext.getCmp('grid').getfilteredStore());
But issue with this code is : Ext.getCmp('grid').getfilteredStore()
get triggered on page load only, not on change
of combo.
Below is code which create combo whenever required
Ext.create('Comboclass', {
id: 'comboId'});
Below is combo class
Ext.define('Comboclass', {
extend: 'Ext.Container',
initComponent: function () {
Ext.apply(this, {
items: [{
xtype: 'combo',
id: this.id,
store: store1
listeners: {
beforeselect : function (combo, r, index) {
if (r.data.id && r.data.id < 0) {
r.data.selectable = false;
return r.data.selectable;
}
},
change: function (field, newValue, oldValue) {
console.log('in dropdown');
}
}
}]
});
this.callParent(arguments);
}
});
Can any one help to solve this issue?
Thanks in advance.
Upvotes: 0
Views: 1272
Reputation: 30082
Because you're executing the function. on
expects a reference to a function.
It's the difference between:
var x = fn(); // x now contains the result of fn
var y = fn; // y now points to the function
You need to remove the last parentheses:
Ext.getCmp('combo1').on('change', Ext.getCmp('grid').getfilteredStore);
Upvotes: 1