PDA

View Full Version : Help with controller actions



brunoflmg
30 Oct 2012, 4:24 AM
Hello Guys,

I need a help with controller actions...

I have a grid with toolbar buttons... the property "action" says to my controller with action I'll use... as follow:



// My view

Ext.define('Myproject.view.person.List',{

extend: 'Ext.grid.Panel'
alias: 'widget.personlist',
[...] // other properties

initComponent: function(){
this.dockedItems = [{
xtype: 'toolbar',
dock: 'top',
itemId: 'dockButtonTop',
items: [{
text: 'Insert',
iconCls: 'add',
menu: new Ext.menu.Menu({
items: [{
text: 'Person type one',
iconCls: 'user',
scope: this,
action: 'addone'
},{
text: 'Person type two',
iconCls: 'user',
scope: this,
action: 'addtwo'
}]
})
},{
text: 'Edit',
action: 'edit',
iconCls: 'edit'
}]
}]

this.callParent(arguments);
}
}


The problem is... my actions addone and addtwo does nothing in my controller. I think this buttons in the Ext.menu.Menu component was not binding the actions that I defined.



// my controller

Ext.define('Myproject.controller.Person',{
extend: 'Ext.app.Controller',
[...]
views : [
'person.List'
],
refs: [{
ref: 'gridList',
selector: 'personlist'
}],
init: function(){
this.control({
'personlist button[action=addone]': {
click: function(){
console.log('test one');
}
},
'personlist button[action=addtwo]': {
click: function(){
console.log('test one');
}
},
'personlist button[action=edit]': {
click: function(){
console.log('edit test');
}
}
});
}
}


So when I press the buttons inside my context buttons located in my toolbar nothing happens. The edit button works fine! :(

What I suppose to do?

James Goddard
30 Oct 2012, 4:51 AM
try:

personlist menuitem [action=addone]

If that doesn't work you may have to use just:

menuitem[action=addone]

Since I'm not sure if the menuitem would wind up being a child of the personlist as it is a popover.

brunoflmg
30 Oct 2012, 4:57 AM
Great! It's works man!



'personlist menuitem[action=addone]': {
click: [...]
}


Thanks!