Extjs 使用relayEvent
我有一个简单的DelButton类: DelButton = Ext.extend(Ext.Button, { ,disabled: false ,listeners: { ,selectionchange: function() { alert('!!!!'); } ,initComponent:function() { this.relayEvents(this.grid.getSelectionModel(), ['selectionchange']); DelButton.superclass.initComponent.call(this); } }); DelButton=Ext.extend(Ext.Button{ ,已禁用:false ,听众:{ ,selectionchange:function(){ 警惕(“!!!!”); } ,initComponent:function(){ this.relayEvents(this.grid.getSelectionModel(),['selectionchange']); DelButton.superclass.initComponent.call(this); } }); buildTBar:函数(配置){ config.tbar={} config.tbar.push(newdelbutton({grid:this})) } , buildConfig:function(config){ this.buildTBar(配置) } , AbstractEditorRidPanel=Ext.extend(Ext.grid.EditorRidPanel{ initComponent:function(){ 变量配置={ 默认值:{border:true,autoHeight:false} }; 这个.buildConfig(config); Ext.apply(this,Ext.apply(this.initialConfig,config)); AbstractEditorGridPanel.superclass.initComponent.call(this); }Extjs 使用relayEvent,extjs,extjs4,Extjs,Extjs4,我有一个简单的DelButton类: DelButton = Ext.extend(Ext.Button, { ,disabled: false ,listeners: { ,selectionchange: function() { alert('!!!!'); } ,initComponent:function() { this.relayEvents(this.grid.getSelection
为什么relayEvent在这种情况下不起作用?(this.grid.getSelectionModel存在)您有一些小问题。请尝试以下操作:
AbstractEditorGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
initComponent:function() {
var config = {
defaults:{border:true, autoHeight:false }
};
this.buildConfig(config);
Ext.apply(this, Ext.apply(this.initialConfig, config));
this.callParent(arguments);
},
buildTBar: function(config) {
config.tbar = [];
config.tbar.push(new DelButton({grid:this, text: 'Text'}))
},
buildConfig:function(config) {
this.buildTBar(config)
}
});
为什么要从按钮中触发“selectionchange”? buildConfig:function(config) { this.buildTBar(config) } AbstractEditorGridPanel = Ext.extend(Ext.grid.EditorGridPanel, { initComponent:function() { var config = { defaults:{border:true, autoHeight:false } }; this.buildConfig(config); Ext.apply(this, Ext.apply(this.initialConfig, config)); AbstractEditorGridPanel.superclass.initComponent.call(this); }
AbstractEditorGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
initComponent:function() {
var config = {
defaults:{border:true, autoHeight:false }
};
this.buildConfig(config);
Ext.apply(this, Ext.apply(this.initialConfig, config));
this.callParent(arguments);
},
buildTBar: function(config) {
config.tbar = [];
config.tbar.push(new DelButton({grid:this, text: 'Text'}))
},
buildConfig:function(config) {
this.buildTBar(config)
}
});