日期:2014-05-16 浏览次数:20389 次
//store/Users.js Ext.define('ERP.store.Users', { extend: 'Ext.data.Store', model: 'ERP.model.User', autoLoad: false, pageSize: 15, autoSync: true, proxy: { type: 'ajax', api: { read: '/User/Search', update: '/User/SaveUser' }, reader: { type: 'json', root: 'rows', totalProperty: 'totalCount', successProperty: 'success' } }, initComponent: function() { this.callParent(); } }); //controller/User.js Ext.define('ERP.controller.User', { extend: 'Ext.app.Controller', stores: ['Users'], models: ['User'], views: ['user.Portal', 'user.List', 'user.Edit'], init: function() { // console.log('Initialized User! This happens before the Application launch function is called'); this.control({ 'userlist': { itemdblclick: this.editUser }, 'useredit button[action=save]': { click: this.updateUser }, 'userportal button[action=hello]': { click: this.hello } }); }, editUser: function(grid, record) { var view = Ext.widget('useredit'); view.down('form').loadRecord(record); }, updateUser: function(button) { console.log('Click the save button'); var win = button.up('window'), form = win.down('form'), record = form.getRecord(), values = form.getValues(); record.set(values); this.getUsersStore().sync(); //这里应该跳到store的update:/User/SaveUser // // this.getStore('Users').sync();//同步 win.close(); }, hello: function(button) { alert('hello'); } });