PDA

View Full Version : View getter



dsultanov
9 Jul 2013, 11:59 PM
I read a lot of similar questions in the forums and the solution seems simple enough, I did everything the same, but did not get the result.

Everywhere they write that to get getter for view only need to register xtype or alias in view (for example, I have a window xtype: 'newUserWindow' ), then the controller register:

refs: [{
ref: 'newuserwindow', / / ??the name you want for getter
selector: 'newUserWindow' / / views alias / xtype
}]

and then just this.getNewuserwindow (). show ();//Getters are composed of get plus the reference selector with uppercase first letter.

I'm in this case always get the error: Uncaught TypeError: Object [object Object] has no method 'Newuserwindow'

Please help...


Ext.define('ReportsApp.view.report.newUserWindow', {
extend: 'Ext.window.Window',
xtype: 'newUserWindow',
//alias: 'newUserWindow',
frame: true,
title: '?????????? ?????? ????????????',
width: 330,
closable: false,
items: Ext.create("ReportsApp.view.report.newUserForm")
});




Ext.define('ReportsApp.controller.AdminPanelControl', {
extend: 'Ext.app.Controller',
views: [
'report.AdminPanel',
'report.AdminPanelGrid',
'report.newUserWindow',
'report.newUserForm'
],
stores: ['AdminPanelStore'],
refs: [{ref: 'newuserwindow', selector: 'newUserWindow'}
],
init: function() {
this.control({
'#deleteUser': {
click: this.onRemoveClick
},
'#addUser': {
click: this.onAddClick
},
'#cancel': {
click: this.onCancelClick
}


});
},
onAddClick: function() {

var store = Ext.getStore('AdminPanelStore');
var rec = store.getProxy().getModel().create();

var nuw = this.Newuserwindow().show();

},
onCancelClick: function() {

},
userEdit: function(rec) {

}

});

Ilay
10 Jul 2013, 4:17 AM
Ext.define('ReportsApp.view.report.newUserWindow', { extend: 'Ext.window.Window', xtype: 'newUserWindow', alias: 'widget.newUserWindow', frame: true, title: '?????????? ?????? ????????????', width: 330, closable: false, items: Ext.create("ReportsApp.view.report.newUserForm")});change your code like this, and it's should be work :)

friend
10 Jul 2013, 4:18 AM
I define xtypes as shown below, where this always works for me:



Ext.define('ReportsApp.view.report.newUserWindow', {
extend: 'Ext.window.Window',
alias: 'widget.newUserWindow',
frame: true,
title: '?????????? ?????? ????????????',
width: 330,
closable: false,
items: Ext.create("ReportsApp.view.report.newUserForm")
});

dsultanov
10 Jul 2013, 4:49 AM
Thanks, but it does not work, the same error: Uncaught TypeError: Object [object Object] has no method 'Newuserwindow'

I think the point is the controller, not in view

Ilay
10 Jul 2013, 5:27 AM
In your code :

var nuw = this.Newuserwindow().show();
maybe it should be
var nuw = this.getNewuserwindow().show();

dsultanov
10 Jul 2013, 5:47 AM
Oh, thank you, I forgot, and now I'm one step closer to my goal, but still do not understand why I still can not turn to him: Uncaught TypeError: Cannot call method 'show' of undefined

It seems that the reason is scope