PDA

View Full Version : MVC add click event on the icon add form the controller



whisher
17 Jan 2012, 2:17 AM
Hi,


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
}
]
});


I've added a simple add delete toolbar to my grid but how
I can add an event listener to my controller - controll for
the add button ?



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
}
});
},

whisher
17 Jan 2012, 3:13 AM
I've added an id


items: [{
iconCls: 'icon-add',
id: 'b-add',
text: 'Add',
scope: this

}


and than simply



'userlist > toolbar > button#b-add': {
click: this.insertUser
}


Thanks the same