I just got through the Ext JS 4 MVC Application Architecture guide (http://docs.sencha.com/ext-js/4-0/#!...n_architecture) and am now going back and tweaking things to try and learn more. One of the first things I decided to do was to change the main grid view from a single grid that pops up a window, into a panel with a border layout that has the grid in the center region and a form in the east region. My "app.js" looks like this:
Code:
Ext.Loader.setConfig({enabled:true});
Ext.application({
name: 'AM',
appFolder: 'app',
controllers: [
'Users'
],
launch: function() {
Ext.create('Ext.container.Viewport', {
xtype: 'panel',
layout: 'border',
items: [
{
xtype: 'userlist',
region: 'center'
},
{
xtype: 'useredit',
region: 'east'
}
]
});
}
});
My "useredit" view looks like this:
Code:
Ext.define('AM.view.user.Edit', {
extend: 'Ext.panel.Panel',
alias: 'widget.useredit',
title: 'Edit User',
layout: 'fit',
autoShow: true,
initComponent: function(){
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name: 'name',
fieldLabel: 'Name'
},
{
xtype: 'textfield',
name: 'email',
fieldLabel: 'Email'
}
]
}
];
this.buttons = [
{
text: 'Save',
action: 'save'
},
{
text: 'Cancel',
scope: this,
handler: this.close
}
];
this.callParent(arguments);
}
});
The Users controller looks like this:
Code:
Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users'],
models: ['User'],
views: [
'user.List',
'user.Edit'
],
init: function() {
this.control({
'userlist': {
itemdblclick: this.editUser
},
'useredit button[action=save]': {
click: this.updateUser
}
});
},
editUser: function(grid, record) {
var view = Ext.widget('useredit');
var form = view.down('form');
console.log("editUser " + record.get('name'));
view.down('form').loadRecord(record);
},
updateUser: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
win.close();
},
showScrollBar: function(grid, record) {
var view = Ext.widget('userlist');
console.log(view.title);
view.title = "New Title";
console.log(view.title);
view.getView('userlist').refresh();
}
});
I can't get a record to load in the form. The useredit does not display the values. However, if I change the view to extend Ext.window.Window, then it displays as a window and loads the record. How do I get the record to load as an "Ext.panel.Panel"? Thanks in advance.