我已經添加了一個工具欄到我的網格 我無法綁定控制器/控制中的事件 當代碼解釋它本身時,它是無聊的:)Extjs將事件添加到網格形式的按鈕控制器
Ext.define('SA.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.userlist',
title : 'All Users',
store: 'Users',
initComponent: function() {
this.columns = [
{
header: 'Id',
sortable: true,
dataIndex: 'id',
flex: 1,
field: {
type: 'textfield'
}
},
{
header: 'Name',
sortable: true,
dataIndex: 'uname',
flex: 1,
field: {
type: 'textfield'
}
},
{
header: 'Email',
sortable: true,
dataIndex: 'email',
flex: 1,
field: {
type: 'textfield'
}
}
];
this.callParent(arguments);
},
dockedItems: [
{
xtype: 'toolbar',
items: [{
iconCls: 'icon-add',
text: 'Add',
scope: this
}, {
iconCls: 'icon-delete',
text: 'Delete',
disabled: true,
itemId: 'delete',
scope: this
}]
},
{
xtype: 'pagingtoolbar',
store: 'Users', // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}
]
});
如何能在控制器內處理程序中的單擊事件形式
init: function() {
this.control({
'userlist': {
itemdblclick: this.editUser
},
'userlist > toolbar/*my attempt but it doesnt work :(*/': {
click: this.insertUser
},
'useredit button[action=save]': {
click: this.updateUser
}
});
},
再見
我做了一招:)的xtype: '工具欄', 項目:[{ iconCls: '圖標添加', ID: 'B-ADD', 文字: '添加', 範圍: }'userlist> toolbar> button#b-add' – Whisher 2012-01-17 10:49:31
這不是一個好主意。使用嚴格的ID是不好的做法。 – erlrange 2012-01-17 14:15:01