日期:2014-05-16 浏览次数:20686 次
Ext.application({ name:'AM', appFolder:'js', controllers:["Users"], launch: function () { Ext.create('Ext.container.Viewport', { layout: 'fit', items: [{ xtype: 'userlist' }] }); } });
Ext.define('AM.controller.Users', { extend: 'Ext.app.Controller', views: [ 'List', 'Edit' ], stores:[ "Users" ], models:["User"], init: function () { this.control({ 'userlist': { itemdblclick: this.editUser } }); }, editUser: function(grid, record) { console.log('Double clicked on ' + record.get('name')); } });
Ext.define('AM.model.User', { extend: 'Ext.data.Model', fields: ['name', 'email'] })
Ext.define('AM.store.Users', { extend: 'Ext.data.Store', model: 'AM.model.User', data: [ { name: 'Ed', email: 'ed@sencha.com' }, { name: 'Tommy', email: 'tommy@sencha.com' } ] });
Ext.define('AM.view.List', { extend: 'Ext.grid.Panel', alias: 'widget.userlist', title: 'All Users', initComponent: function () { this.store = "Users"; this.columns = [ { header: 'Name', dataIndex: 'name', flex: 1 }, { header: 'Email', dataIndex: 'email', flex: 1 } ]; this.callParent(arguments); } });