Problem
Hello the inconvenient is that when I load my application the handler is automatically executing, this is the code of the grid:
Ext.define('masterDataGrid', {
extend : 'Ext.grid.Panel',
windowItems : null,
addWin : null,
initComponent : function() {
var me = this;
Ext.applyIf(me, {
tbar : [{
text : 'Add',
handler :me.onAdd,
scope : me
}, '-', {
text : 'Delete',
handler : me.onDelete,
scope : me
}, '-']
});
me.callParent(arguments);
},
getAddWindow : function() {
if (!this.addWin) {
this.addWin = new windowPop({
buttons : [{
text : 'i_OK',
handler : this.winOk()
}, {
text : 'i_Cancel',
handler : this.winCancel()
}]
});
this.addWin.add(this.windowItems);
}
return this.addWin;
},
onAdd : function() {
var addWindow = this.getAddWindow();
addWindow.show();
},
});
And I’m calling this mastergrid form another class that extends from it, this is the code:
Ext.define('confEmailEmail', {
extend : 'masterDataGrid',
initComponent : function() {
var me = this;
me.columns = [{
id : 'code',
header : 'code',
dataIndex : 'code',
width : 220
}, {
header : 'description',
dataIndex : 'description',
width : 130
}, {
header : 'multiply',
dataIndex : 'multiply',
width : 70,
align : 'right'
}, {
header : 'cyrcletime',
dataIndex : 'cycletime',
width : 95
}];
me.windowItems = [{
xtype : 'combobox',
id : 'cb_input',
fieldLabel : 'i_Input',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120
}, {
xtype : 'checkbox',
id : 'chk_invert',
fieldLabel : 'i_Invert',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120
}, {
xtype : 'combobox',
id : 'cb_activeBy',
fieldLabel : 'i_Active by',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120
}];
me.callParent(arguments);
}
});
it supposed to open the window to add a new row when I click on the add button but it is showing every time I execute the whole application.
Thanks for any help.
I got it, it is because onAdd is a method for Ext.grid.Panel, then when it is trying to load the application it access to my method onAdd because he thinks that I had overwrote the method onAdd of Ext.grid.Panel.