-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid-panel-example.html
executable file
·94 lines (76 loc) · 2.45 KB
/
grid-panel-example.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<html>
<head>
<title>Stores</title>
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<style>
body{
background-color:#aeaeae;
}
#container{
background-color:#ccc;
}
</style>
<script src="extjs/adapter/ext/ext-base.js"></script>
<script src="extjs/ext-all-debug.js"></script>
<script>
Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
// lets use our ArrayStore
var myStore = new Ext.data.ArrayStore({
data: [
['Ryan Morris', 'NY'],
['Tim Lot', 'MD'],
['Steve Shanigan', 'WA']
],
fields: ['name', 'state']
});
// to set up a GridPanel, we'll need a ColumnModel, GridView and SelectionModel configured
// the ColumnModel will relate to the data fields
// we are configuring what the columns will be and how they map to the Store's data fields
var colModel = new Ext.grid.ColumnModel([
{
header : 'Full Name',
sortable : true, // enable sorting on this column
dataIndex : 'name'
},
{
header: 'State',
dataIndex : 'state'
}
]);
// GridView will manage each individual row in the grid
// responsible for listening for row events and updating the grid when the store updates
var gridView = new Ext.grid.GridView();
// handles selection events on rows
// GridView instantiates one by default w/ multi-select, so we are instantiating one with single select to override
// alternatively you could use the CellSelectionModel
var selModel = new Ext.grid.RowSelectionModel({
singleSelect : true
});
// now set up the GridPanel
// note: NEVER pass a layout to GridPanel
var grid = new Ext.grid.GridPanel({
id: 'myGridPanel',
title : 'Our first grid',
//renderTo : Ext.getBody(),
autoHeight : true,
width : 250,
// special configs for GridPanel...
store : myStore,
view : gridView,
colModel : colModel,
selModel : selModel
});
Ext.onReady(function () {
new Ext.Viewport({
layout : 'hbox',
items : [
grid
]
});
});
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>