2015-12-14 6 views
1

У меня есть следующий вопрос: я пытаюсь передать ссылку контроллера на все элементы под ним. Вы знаете, что я делаю неправильно, я попытался так много posiblities, но я держу неудачу ... меняИспользование ссылки на хранилище во всех вложенных элементах

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();  
    } 
}); 

ответ

1

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)) 
    } 
}); 
+0

Спасибо за подсказки, я буду проверять его как можно скорее, унд затем принять answere, ти :) –

Смежные вопросы