ta powinna działać:
Ext.define('DigitalPaper.controller.Documents', {
extend: 'Ext.app.Controller',
views: ['Documents'],
stores: ['Documents'],
models: ['Documents'],
init: function() {
console.log('[OK] Init Controller: Documents');
// get references to view and model classes which can be used to create new instances
console.log('View', this.getDocumentsView());
console.log('Model', this.getDocumentsModel());
// reference the Documents store
console.log('Store', this.getDocumentsStore());
}
});
Metody te są tworzone za pomocą metody kontrolera Ext, która tworzy moduły pobierające. http://docs.sencha.com/ext-js/4-0/source/Controller.html#Ext-app-Controller
Oto, co to metoda wygląda następująco:
createGetters: function(type, refs) {
type = Ext.String.capitalize(type);
Ext.Array.each(refs, function(ref) {
var fn = 'get',
parts = ref.split('.');
// Handle namespaced class names. E.g. feed.Add becomes getFeedAddView etc.
Ext.Array.each(parts, function(part) {
fn += Ext.String.capitalize(part);
});
fn += type;
if (!this[fn]) {
this[fn] = Ext.Function.pass(this['get' + type], [ref], this);
}
// Execute it right away
this[fn](ref);
},
this);
},
Nikt nigdy nie wydaje się mówić, gdzie "this.getViewDocuments();" musi być - lub "to" jest w kontekście, w którym ludzie oczekują, że go użyję :( –
@PaulHutchinson Korzystając z sekcji "refs" w definicji kontrolera ExtJS, można utworzyć szybkie odwołania do często używanych komponentów. utwórz "getter" metody na podstawie dostarczonego tekstu dla "ref" .W tym przykładzie, utworzony getter jest "getViewDocuments." To może być wywołane w kontrolerze, gdzie "to" odnosi się do zakresu kontrolera. jest używane w wynikowym wywołaniu Ext.ComponentQuery.query(). Zobacz dokumentację dla ComponentQuery.query() i zobacz, jak potężna może być definicja selektora! –