Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / app / simple / app / controller / Users.js
diff --git a/examples/app/simple/app/controller/Users.js b/examples/app/simple/app/controller/Users.js
new file mode 100644 (file)
index 0000000..98282c8
--- /dev/null
@@ -0,0 +1,44 @@
+Ext.define('AM.controller.Users', {
+    extend: 'Ext.app.Controller',
+
+    stores: ['Users'],
+
+    models: ['User'],
+
+    views: ['user.Edit', 'user.List'],
+
+    refs: [
+        {
+            ref: 'usersPanel',
+            selector: 'panel'
+        }
+    ],
+
+    init: function() {
+        this.control({
+            'viewport > userlist dataview': {
+                itemdblclick: this.editUser
+            },
+            'useredit button[action=save]': {
+                click: this.updateUser
+            }
+        });
+    },
+
+    editUser: function(grid, record) {
+        var edit = Ext.create('AM.view.user.Edit').show();
+
+        edit.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();
+        this.getUsersStore().sync();
+    }
+});