EXTJS MVC模式下controller如何绑定'添加'和'删除'这两个button
Ext.define('supplierInfo.view.CompanyQualification',{extend:'Ext.grid.Panel',title:'公...
Ext.define('supplierInfo.view.CompanyQualification', {
extend: 'Ext.grid.Panel',
title: '公司资质',
alias: 'widget.companyqualification',
layout: 'fit',
store: 'CompanyQualification',
columns: [
{text: '证书名称', dataIndex: 'certificateName', editor: 'textfield'},
{text: '发证机关', dataIndex: 'issuingGroup', editor: 'textfield'},
{text: '资质', dataIndex: 'qualification', editor: 'textfield'},
{text: '等级', dataIndex: 'level', editor: 'textfield'},
{text: '有效期', dataIndex: 'validTime', editor: 'textfield'}
],
plugins: {
ptype: 'cellediting',
clicksToEdit: 2
},
initComponent: function(){
// Ext.apply(this ,{
// frame: true,
this.dockedItems= [{
xtype: 'toolbar',
items: [{
text: '添加',
scope: this//,
//handler: this.onAddClick
},{
text: '删除',
scope: this//,
//handler: this.onDeleteClick
}]
}];
// this.button= [{
// text: '添加',
// scope: this
// },{
// text: '删除',
// scope: this
// }];
// });
this.callParent();
}//,
// onAddClick: function(){
// var rec = new supplierInfo.model.CompanyQualification({
// certificateName: '',
// issuingGroup: '',
// qualification: '',
// level: '',
// validTime: ''
// });
//
// this.store.insert(0, rec);
//
// },
// onDeleteClick: function(){
// var selection = this.getView().getSelectionModel().getSelection()[0];
// if(selection) {
// this.store.remove(selection);
// }
// }
}); 展开
extend: 'Ext.grid.Panel',
title: '公司资质',
alias: 'widget.companyqualification',
layout: 'fit',
store: 'CompanyQualification',
columns: [
{text: '证书名称', dataIndex: 'certificateName', editor: 'textfield'},
{text: '发证机关', dataIndex: 'issuingGroup', editor: 'textfield'},
{text: '资质', dataIndex: 'qualification', editor: 'textfield'},
{text: '等级', dataIndex: 'level', editor: 'textfield'},
{text: '有效期', dataIndex: 'validTime', editor: 'textfield'}
],
plugins: {
ptype: 'cellediting',
clicksToEdit: 2
},
initComponent: function(){
// Ext.apply(this ,{
// frame: true,
this.dockedItems= [{
xtype: 'toolbar',
items: [{
text: '添加',
scope: this//,
//handler: this.onAddClick
},{
text: '删除',
scope: this//,
//handler: this.onDeleteClick
}]
}];
// this.button= [{
// text: '添加',
// scope: this
// },{
// text: '删除',
// scope: this
// }];
// });
this.callParent();
}//,
// onAddClick: function(){
// var rec = new supplierInfo.model.CompanyQualification({
// certificateName: '',
// issuingGroup: '',
// qualification: '',
// level: '',
// validTime: ''
// });
//
// this.store.insert(0, rec);
//
// },
// onDeleteClick: function(){
// var selection = this.getView().getSelectionModel().getSelection()[0];
// if(selection) {
// this.store.remove(selection);
// }
// }
}); 展开
2个回答
展开全部
在ExtMVC中通过controller的查找器来查询你的控件,
首先你可以设置你的button的itemId,或者为其加入action属性,
代码如下:
...//此处省略代码
this.button= [{
text: '添加',
scope: this,
itemId:'add'
},{
text: '删除',
scope: this,
action:'delete'
}];
在controller中邦定事件
代码如下:
Ext.define('YourControllerSrc',{//你controller的地址
extend:'Ext.app.Controller',
init:function(){
this.control({
"companyqualification #add":{//添加按钮点击事件
click:function(obj){}
}
"companyqualification [action=delete]":{//删除按钮点击事件
click:function(obj){}
}
});
}
})
个人建议使用第二种 避免id重复
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询