Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / app / simple / app / controller / Users.js
1 Ext.define('AM.controller.Users', {
2     extend: 'Ext.app.Controller',
3
4     stores: ['Users'],
5
6     models: ['User'],
7
8     views: ['user.Edit', 'user.List'],
9
10     refs: [
11         {
12             ref: 'usersPanel',
13             selector: 'panel'
14         }
15     ],
16
17     init: function() {
18         this.control({
19             'viewport > userlist dataview': {
20                 itemdblclick: this.editUser
21             },
22             'useredit button[action=save]': {
23                 click: this.updateUser
24             }
25         });
26     },
27
28     editUser: function(grid, record) {
29         var edit = Ext.create('AM.view.user.Edit').show();
30
31         edit.down('form').loadRecord(record);
32     },
33
34     updateUser: function(button) {
35         var win    = button.up('window'),
36             form   = win.down('form'),
37             record = form.getRecord(),
38             values = form.getValues();
39
40         record.set(values);
41         win.close();
42         this.getUsersStore().sync();
43     }
44 });