app.js
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @example Grouping Grid Panel
*
* A grid panel that demonstrates grouping rows using the {@link Ext.grid.feature.Grouping} feature
*/
Ext.require('Ext.data.Store');
Ext.require('Ext.grid.Panel');
Ext.define('Employee', {
extend: 'Ext.data.Model',
fields: [ 'name', 'seniority', 'department' ]
});
Ext.onReady(function() {
var employeeStore = Ext.create('Ext.data.Store', {
model: 'Employee',
data: [
{ name: 'Michael Scott', seniority: 7, department: 'Management' },
{ name: 'Dwight Schrute', seniority: 2, department: 'Sales' },
{ name: 'Jim Halpert', seniority: 3, department: 'Sales' },
{ name: 'Kevin Malone', seniority: 4, department: 'Accounting' },
{ name: 'Angela Martin', seniority: 5, department: 'Accounting' }
],
groupField: 'department'
});
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
store: employeeStore,
width: 200,
height: 300,
title: 'Employees - Scranton Branch',
columns: [
{
text: 'Name',
width: 100,
dataIndex: 'name'
},
{
text: 'Seniority',
flex: 1,
dataIndex: 'seniority'
}
],
features: [{ ftype: 'grouping' }]
});
});