1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Ext.define('sample.controller.Main', {
extend : 'Ext.app.Controller',
models : ['MainStore'],
stores : [' MainStore '],
views : ['Main'],
requires : ['Ext.MessageBox'],
init: function() {
//ajouter des listener sur les événement du datastore.
Ext.getStore('MainStore').addListener('load', this.onMainStoreLoad, this);
Ext.getStore('MainStore').addListener('datachanged', this.onMainStoreDataChange, this);
this.control({
// A sample combo box select function
'combo[action=sampleSelect]':{
select:this.onComboSelect
},
// A sample button click function
'button[action=sampleAction]':{
click:this.onButtonClick
}
});
},
// This is where all the functions go
onComboSelect: function(combo) {
console.log('ComboBox Selected, the value is:' + combo.getValue()) ;
},
onButtonClick: function(me){
console.log('Button Clicked');
},
onMainStoreLoad: function(me,records,success){
if(!success){
Ext.MessageBox.show({
title : 'Data Load Error',
msg : 'The data encountered a load error, please try again in a few minutes.'
});
}
},
onMainStoreDataChange: function(me){
console.log('Hey the store data just changed!');
}
}); |
Partager