I'm just beginning with Extjs 4, and I need to get the selected value of a combobox to change stores and rendering a chart corresponding to the data of each store.
I'm using the MVC model, here's my view containing comboboxes :
Ext.define('Metrics.view.Params', {
extend: 'Ext.grid.Panel',
alias: 'widget.params',
title: 'Select Parameters',
hideHeaders: true,
initComponent: function() {
this.columns = [{
dataIndex: 'name',
flex: 1
}];
this.dockedItems = [{
xtype: 'container',
items: [{
xtype: 'combobox',
id : 'cmbGraph',
mode : 'queryMode',
name : 'graph',
fieldLabel: 'Graph',
store: ['Small data','Big data'],
editable : false
},
{
//another combobox here..
}]
And my controller is :
Ext.define('Metrics.controller.RenderGraph', {
extend: 'Ext.app.Controller',
refs: [{
ref : 'params',
selector : 'params'
}],
stores: ['GraphData'],
init: function() {
// Start listening for events on views
this.control({
'paramsbtn button[action=apply]': {
click : this.launchChart
}
});
launchChart : function(button){
var params = this.getParams();
var combo1 = params.items[cmbGraph];
console.log(Ext.encode(combo1));
var v = combo1.getValue();
var r = combo1.findRecord(combo1.valueField || combo1.displayField,v);
return(combo1.store.indexOf(r));
console.log('combo item' + r + 'selected');
}
As you can see, I'm trying to get the value of the combobox with the ID = cmbGraph, but it's not working, the error message I get is :
Uncaught TypeError: Cannot call method 'getValue' of undefined
It's complicated with Extjs 4 because I have to get to an element of a view with my controller. Any help would be much appreciated.