]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/classic/state/state.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / classic / state / state.js
CommitLineData
6527f429
DM
1Ext.require([\r
2 'Ext.grid.*',\r
3 'Ext.window.Window',\r
4 'Ext.container.Viewport',\r
5 'Ext.layout.container.Border',\r
6 'Ext.state.*',\r
7 'Ext.data.*'\r
8]);\r
9\r
10Ext.define('Person', {\r
11 extend: 'Ext.data.Model',\r
12 fields: ['first', 'last', 'review', {\r
13 name: 'age',\r
14 type: 'int'\r
15 }]\r
16});\r
17\r
18Ext.onReady(function(){\r
19\r
20 // setup the state provider, all state information will be saved to a cookie\r
21 Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));\r
22\r
23 Ext.create('Ext.container.Viewport', {\r
24 layout: {\r
25 type: 'border',\r
26 padding: '5'\r
27 },\r
28 items: [{\r
29 region: 'north',\r
30 height: 170,\r
31 bodyPadding: 5,\r
32 split: true,\r
33 html: [\r
34 'Between refreshes, the grid below will remember',\r
35 '<ul>',\r
36 '<li>The hidden state of the columns</li>',\r
37 '<li>The width of the columns</li>',\r
38 '<li>The order of the columns</li>',\r
39 '<li>The sort state of the grid</li>',\r
40 '</ul>'\r
41 ].join(''),\r
42 dockedItems: [{\r
43 xtype: 'toolbar',\r
44 items: [{\r
45 text: 'Show window',\r
46 handler: function(btn){\r
47 Ext.create('Ext.window.Window', {\r
48 width: 300,\r
49 height: 300,\r
50 x: 5,\r
51 y: 5,\r
52 title: 'State Window',\r
53 maximizable: true,\r
54 stateId: 'stateWindowExample',\r
55 stateful: true,\r
56 bodyPadding: 5,\r
57 html: [\r
58 'Between refreshes, this window will remember:',\r
59 '<ul>',\r
60 '<li>The width and height</li>',\r
61 '<li>The x and y position</li>',\r
62 '<li>The maximized and restore states</li>',\r
63 '</ul>'\r
64 ].join(''),\r
65 listeners: {\r
66 destroy: function(){\r
67 btn.enable();\r
68 }\r
69 }\r
70 }).show();\r
71 btn.disable();\r
72 }\r
73 }]\r
74 }]\r
75 }, {\r
76 bodyPadding: 5,\r
77 region: 'west',\r
78 title: 'Collapse/Width Panel',\r
79 width: 240,\r
80 stateId: 'statePanelExample',\r
81 stateful: true,\r
82 split: true,\r
83 collapsible: true,\r
84 html: [\r
85 'Between refreshes, this panel will remember:',\r
86 '<ul>',\r
87 '<li>The collapsed state</li>',\r
88 '<li>The width</li>',\r
89 '</ul>'\r
90 ].join('')\r
91 }, {\r
92 region: 'center',\r
93 stateful: true,\r
94 stateId: 'stateGridExample',\r
95 xtype: 'grid',\r
96 store: Ext.create('Ext.data.Store', {\r
97 model: 'Person',\r
98 data: [{\r
99 first: 'John',\r
100 last: 'Smith',\r
101 age: 32,\r
102 review: 'Solid performance, needs to comment code more!'\r
103 }, {\r
104 first: 'Jane',\r
105 last: 'Brown',\r
106 age: 56,\r
107 review: 'Excellent worker, has written over 100000 lines of code in 3 months. Deserves promotion.'\r
108 }, {\r
109 first: 'Kevin',\r
110 last: 'Jones',\r
111 age: 25,\r
112 review: 'Insists on using one letter variable names for everything, lots of bugs introduced.'\r
113 }, {\r
114 first: 'Will',\r
115 last: 'Zhang',\r
116 age: 41,\r
117 review: 'Average. Works at the pace of a snail but always produces reliable results.'\r
118 }, {\r
119 first: 'Sarah',\r
120 last: 'Carter',\r
121 age: 23,\r
122 review: 'Only a junior, but showing a lot of promise. Coded a Javascript parser in Assembler, very neat.'\r
123 }]\r
124 }),\r
125 columns: [{\r
126 text: 'First Name',\r
127 width:110,\r
128 dataIndex: 'first'\r
129 }, {\r
130 text: 'Last Name',\r
131 width:110,\r
132 dataIndex: 'last'\r
133 }, {\r
134 text: 'Age',\r
135 width:60,\r
136 dataIndex: 'age'\r
137 }, {\r
138 flex: 1,\r
139 text: 'Review',\r
140 dataIndex: 'review'\r
141 }]\r
142 }]\r
143 });\r
144});