我有以下问题,我试图将控制器的引用传递给下面的所有项目。你知道我做错了什么我尝试了这么多的可能性,但我一直都在失败...... 我有
Ext.define('playground.view.MainTabPanel', {
extend: 'Ext.tab.Panel',
requires: ['playground.view.DrawItemsGrid', 'playground.view.DrawItemsList', 'playground.view.Graph'],
layout: 'vbox',
config:{
store: Ext.data.StoreManager.get('DrawItemsStore')
},
initComponent: function() {
this.callParent(arguments);
this.add( Ext.create('playground.view.DrawItemsList', {
store: this.store,
title: 'List'
}));
this.add( Ext.create('playground.view.DrawItemsGrid',{
store: this.store,
title: 'Grid'
}));
this.setActiveTab(0);
}
});
Ext.define('playground.controller.LabeledSliders', {
extend : 'Ext.app.Controller',
stores : ['DrawItemsStore'],
views : ['playground.view.DrawItemsGrid', 'playground.view.DrawItemsList'], //, 'playground.view.MainTabPanel']
init: function() {
this.control({
'slider': {
change: this.onSliderChanged
}
});
},
onSliderChanged: function(){
var label = arguments[0].fieldLabel;
var value = arguments[2].value;
var store = Ext.data.StoreManager.get(this.stores[0]);
// var store = this.store; THIS IS WHERE MY THIS DOES NOT BEKOME THE REFERENCE
var rec = store.findRecord('label', label);
if(rec.get('value') != value){
rec.updateValue(value);
// this.getController('Graphs').drawGraph();
}
}
});
HIS IS WHERE MY THIS DOES NOT BEKOME THE REFERENCE - is the place where i was hopeing to see there reference not undefined
Ext.define('playground.controller.Graphs', {
extend : 'Ext.app.Controller',
// stores : ['DrawItemsStore'],
views : ['playground.view.Graph'],
init: function(){
// console.log('init Graphs ctrl');
this.control({
'graph' :{
'drawGraph': function (e, opts){ this.drawGraph(e, opts) }
},
});
},
drawGraph: function(e, opts){
console.log('draw graph');
// var view = this.getPlaygroundViewGraphView();
// view.setStore(this.store);
var graph = Ext.create('playground.drawings.RadarGraph', { store: ''});
e.add(graph);
e.doLayout();
}
});
答案 0 :(得分:1)
设置控制器后,控制器无法使用stores
配置属性。相反,对于stores数组中定义的每个商店,您将获得一个可以调用的函数。对于名为MyStore1
的商店,该函数将为this.getMyStore1()
:
Ext.define('ConfigurationController',{
extends:'Ext.app.Controller',
stores:['ConfigStore'],
init: function() {
var me = this;
this.control({
'configForm field': {
change: me.onConfigFormFieldChange
}
});
},
onConfigFormFieldChange: function(field) {
field.up('form').updateRecord(this.getConfigStore().getAt(0))
}
});