PDA

View Full Version : How to add event listeners to components from controller and how to call data.json



agarapati
9 Jun 2015, 6:35 AM
The code is in the below url. In app/controller/Home.js Controller file, I created store to get checkboxes data from "data/data1.json" (In method "getLeftNav") but the store is not returning any values where did I do mistake.

https://fiddle.sencha.com/#fiddle/o9n

In ur project we have our own architecture which is built on ExtJs where we have a config section event inside which we can add event listeners to components defined in view. In Pure ExtJs 4.2.2 how to add listeners in controller. (Assume I need change event to be triggered on combo box defined in app/view/Home.js). Combo box code



{
xtype: 'radiogroup',
id: 'filterRadioGroup',
border: false,
columns: 1,
padding: '10 0 0 0',
defaults: {
labelWidth: 280,
labelAlign: 'left',
minWidth: 280,
maxWidth: 280
},
items: [
{
boxLabel: 'Show All',
checked: true,
name: 'filtertype',
inputValue: 'All'
}, {
boxLabel: 'My Choice',
name: 'filtertype',
inputValue: 'MyInvest'
}
]
}

scottmartin
10 Jun 2015, 5:16 PM
In your controller, you can use the following approaches for controller access:



refs : [
{
ref : 'editPanel',
selector : 'my-form'
},
{
ref : 'gridPanel',
selector : 'my-grid'
}

],

init : function () {
var me = this;

me.control({
'my-grid' : {
selectionchange : me.onSelecChange,
..
},

// all combos on form
'my-form combobox' : {
beforequery : me.onComboQuery
},

'my-form button[action=saveChanges]' : {
click : me.onSaveChanges
}

});

me.listen({
store: {
'#Users' : {
beforeload : function(store, operation, eOpts) {
},
}
}
});

},

onSelecChange : function () {
var me = this,
gridPanel = me.getGridPanel(); // ref getter
},

agarapati
10 Jun 2015, 10:17 PM
Thanks Scott now I understood it :)