PDA

View Full Version : MVC : Getting view references



manube
27 Sep 2011, 1:05 AM
Hello,

I'm trying to use the view getters from the MVC model and I'm only getting functions that I cannot use.
For instance, in my following example, MyView extends 'Ext.grid.Panel' and I cannot (don't know how to) access to the selection model :

Ext.define('MyApp.controller.MyController', {
extend : 'Ext.app.Controller',
models : [ ... ],
stores : [ ... ],
views : [ 'foo.bar.MyView' ],
...
myFunction: function()
{
var me = this;
var view = me.getFooBarMyViewView();
console.log(view); //->Returns function() and I don't know what to do with this ...
view.getSelectionModel(); // -> Throws exception
view.getView(); // -> Throws exception

}


Thanks

skirtle
27 Sep 2011, 3:03 AM
The getter will give you back the class, not an instance. The function you're seeing is the constructor.

See the section Generated getter methods:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.app.Controller

manube
27 Sep 2011, 3:37 AM
Thanks.

I probably misunderstood this documentation :

var User = this.getUserModel(),
allUsers = this.getAllUsersStore();
var ed = new User({name: 'Ed'});
allUsers.add(ed);

It seems that this.getAllUsersStore() returns a store that I can use directly (add, sync ...).
But anyway, thank you for this information, it will help me a lot.