View Full Version : Problem event on click button event

11 Jun 2013, 3:45 AM

I'm trying to reuse a working code from a previous application but it doesn't work in the new one.

I've created a button in my grid and I've put an event on click in my controller. At the moment just trying to display an alert message but nothing happen when I click on the button.

Anyone has an idea what could be wrong?

Thanks in advance

Ext.define('SPI.controller.ViewPort', {
extend: 'Ext.app.Controller',
requires: 'Ext.window.MessageBox',
models: ['tree', 'Grid', 'Country','LoadedCode'],

stores: [ 'treeTrade', 'treeRevOne', 'treeNaceOne', 'treeRevTwo', 'treeNaceTwo',
'gridTrade', 'gridRevOne', 'gridCountry', 'comboCountries',

views: ['trees.Trade', 'trees.Sectors', 'trees.NaceOne', 'trees.RevOne',
'trees.NaceTwo', 'trees.RevTwo', 'trees.CountryLevel',
'grids.RevOne', 'grids.CountryLevel',
'combos.Years', 'combos.Countries'], //

init: function () {
var me = this;

'rev1Tree': {
checkchange: me.application.getController('Trees').loadDataFromRev1
'nace1Tree': {
checkchange: me.application.getController('Trees').loadDataFromNace1
'countryLevelTree': {
// beforeitemdblclick: me.application.getController('Trees').tickChildren,
checkchange: me.application.getController('Trees').loadDataFromCountry
'sectorTree': {
checkchange: me.displayData
'button[action = cls]': {
click: this.clearData

clearData: function (){

Ext.define('SPI.view.grids.CountryLevel', {
extend: 'Ext.grid.GridPanel',
alias : 'widget.countryGrid',
store: 'gridCountry',
sortableColumns: false,
menuDisabled: true,
loadMask: 'Please wait',
dockedItems: [ {
xtype: 'toolbar',
items: [
xtype: 'button',
action: 'exportToExcel',
text: 'Export',
icon: 'app/view/icons/icon_xls.gif'
xtype: 'button',
action: 'txtExport',
icon: 'app/view/icons/file_txt.png',
text: 'Text export'
xtype: 'button',
action: 'cls',
text: 'Clear',
icon: 'app/view/icons/delete.png',
tooltip: 'Reset all data'

11 Jun 2013, 3:51 AM
What does the selector mean?

'action '=' cls'?

11 Jun 2013, 4:09 AM
What do you mean?

in my grid--> action: 'cls'
in my controller: 'button[action=cls]':

Does cls a reserved word?

11 Jun 2013, 4:12 AM
Well ok, I've written the following and it works:

grid --> action: 'clearData'
controller -- > 'button[action="clearData"]':

I'm not sure if the problem came from the 'cls' name I gave or because I didn't put "" between the word.