1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | Ext.ns('App'); |
---|
10 | |
---|
11 | App.EmployeeGrid = Ext.extend(Ext.grid.GridPanel, { |
---|
12 | initComponent: function() { |
---|
13 | this.columns = [ |
---|
14 | {dataIndex: 'lastName', header: 'Name', renderer: this.renderName}, |
---|
15 | {dataIndex: 'department', header: 'Department'}, |
---|
16 | {dataIndex: 'title', header: 'Title'}, |
---|
17 | {dataIndex: 'telephone', header: 'Telephone'}, |
---|
18 | {dataIndex: 'office', header: 'Office'} |
---|
19 | ]; |
---|
20 | this.viewConfig = { |
---|
21 | forceFit: true |
---|
22 | }; |
---|
23 | App.EmployeeGrid.superclass.initComponent.call(this); |
---|
24 | this.getSelectionModel().on('rowselect', this.onRowSelect, this, {buffer: 300}); |
---|
25 | this.store.load(); |
---|
26 | }, |
---|
27 | renderName: function(val, md, record) { |
---|
28 | return String.format('{0}, {1}', val, record.get('firstName')); |
---|
29 | }, |
---|
30 | onRowSelect: function(sm, idx, r) { |
---|
31 | Ext.getCmp('employeeDetails').load(r.id); |
---|
32 | } |
---|
33 | }); |
---|
34 | Ext.reg('employeegrid', App.EmployeeGrid); |
---|