Last active
December 28, 2015 18:09
-
-
Save jpolvora/7540780 to your computer and use it in GitHub Desktop.
Ext Ext.js ActionColumn MVC Estive procurando uma solução para esse problema e de todas as formas que testei, a mais simples no MVC foi a de disparar um evento na view, com o controller capturando este evento. Testado no Ext.js 4.2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('App.controller.Clientes', { | |
extend: 'Ext.app.Controller', | |
init: function () { | |
this.control({ | |
"grid": { | |
meuevento: function (record) { //captura o evento que será disparado pelo grid, quando o ícone for clicado | |
console.log(record); | |
}, | |
meuoutroevento: function (record) { //captura o evento que será disparado pelo grid, quando o ícone for clicado | |
console.log(record); | |
}, | |
} | |
}); | |
self.callParent(arguments); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('App.view.Clientes.Lista', { | |
extend: 'Ext.grid.Panel', | |
initComponent: function () { | |
var self = this; | |
//registra eventos customizados que poderão ser disparados posteriormente | |
self.addEvents({ | |
meuevento: true, | |
meuoutroevento: true | |
}); | |
this.columns = { | |
items: [ | |
{ | |
xtype: 'actioncolumn', | |
text: 'Opções', | |
items: [ | |
{ | |
icon: '/Content/png/21.png', | |
tooltip: 'Primeira Opção', | |
handler: function (view, rowIdx, colIdx, item, e, record) { | |
//dispara um evento customizado, passando o record como parâmetro | |
self.fireEvent('meuevento', record); | |
} | |
}, | |
{ | |
icon: '/Content/png/22.png', | |
tooltip: 'Segunda Opção', | |
handler: function (view, rowIdx, colIdx, item, e, record) { | |
//dispara um evento customizado, passando o record como parâmetro | |
self.fireEvent('meuoutroevento', record); | |
} | |
} | |
] | |
} | |
] | |
}; | |
self.callParent(arguments); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment