]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/classic/samples/view/form/FormGrid.js
bump version to 7.0.0-4
[extjs.git] / extjs / build / examples / kitchensink / classic / samples / view / form / FormGrid.js
CommitLineData
947f0963
TL
1/**
2 * This Form demonstrates the fact that by virtue of inheriting from the Ext.Container
3 * class, an Ext.form.Panel can contain any Ext.Component. This includes all the
4 * subclasses of Ext.Panel, including the GridPanel.
5 *
6 * The Grid demonstrates the use of creation of derived fields in a Record created using a
7 * custom `convert` function, and the use of column renderers.
8 *
9 * The Form demonstrates the use of radio buttons grouped by name being set by the value
10 * of the derived rating field.
11 */
12Ext.define('KitchenSink.view.form.FormGrid', {
13 extend: 'Ext.form.Panel',
14 xtype: 'form-grid',
15 controller: 'form-grid',
16
17 requires: [
18 'Ext.grid.*',
19 'Ext.form.*',
20 'Ext.layout.container.Column',
21 'KitchenSink.model.Company'
22 ],
23
24 //<example>
25 otherContent: [{
26 type: 'Controller',
27 path: 'classic/samples/view/form/FormGridController.js'
28 }],
29 profiles: {
30 classic: {
31 width: 750,
32 gridWidth: 0.6,
33 formWidth: 0.4,
34 priceWidth: 75,
35 pricechangeWidth: 80,
36 percentChangeColumnWidth: 75,
37 lastUpdatedColumnWidth: 85,
38 ratingColumnWidth: 30,
39 gainColor: 'green',
40 lossColor: 'red',
41 labelAlign: 'left',
42 bodyPadding: 5
43 },
44 neptune: {
45 width: 880,
46 gridWidth: 0.65,
47 formWidth: 0.35,
48 priceWidth: 75,
49 pricechangeWidth: 80,
50 percentChangeColumnWidth: 100,
51 lastUpdatedColumnWidth: 115,
52 ratingColumnWidth: 60,
53 gainColor: '#73b51e',
54 lossColor: '#cf4c35',
55 labelAlign: 'left',
56 bodyPadding: 5
57 },
58 graphite: {
59 width: 1150,
60 gridWidth: 0.65,
61 formWidth: 0.35,
62 priceWidth: 100,
63 pricechangeWidth: 110,
64 percentChangeColumnWidth: 130,
65 lastUpdatedColumnWidth: 155,
66 ratingColumnWidth: 90,
67 gainColor: 'unset',
68 lossColor: 'unset',
69 labelAlign: 'left',
70 bodyPadding: 5
71 },
72 'classic-material': {
73 width: 1150,
74 gridWidth: 0.65,
75 formWidth: 0.35,
76 priceWidth: 100,
77 pricechangeWidth: 110,
78 percentChangeColumnWidth: 130,
79 lastUpdatedColumnWidth: 155,
80 ratingColumnWidth: 90,
81 gainColor: 'unset',
82 lossColor: 'unset',
83 labelAlign: 'top',
84 bodyPadding: 0
85 }
86 },
87 //</example>
88
89 title: 'Company data',
90 width: '${width}',
91 frame: true,
92 bodyPadding: '${bodyPadding}',
93 layout: 'column',
94 signTpl: '<span style="' +
95 'color:{value:sign(\'${lossColor}\',\'${gainColor}\')}"' +
96 '>{text}</span>',
97
98 viewModel: {
99 data: {
100 theCompany: null
101 }
102 },
103
104 fieldDefaults: {
105 labelAlign: '${labelAlign}',
106 labelWidth: 90,
107 anchor: '100%',
108 msgTarget: 'side'
109 },
110
111 items: [{
112 xtype: 'gridpanel',
113
114 height: 400,
115 columnWidth: '${gridWidth}',
116
117 bind: {
118 selection: '{theCompany}'
119 },
120 store: {
121 type: 'companies'
122 },
123
124 columns: [{
125 text: 'Company',
126 dataIndex: 'name',
127
128 flex: 1,
129 sortable: true
130 }, {
131 text: 'Price',
132 dataIndex: 'price',
133
134 width: '${priceWidth}',
135 sortable: true
136 }, {
137 text: 'Change',
138 dataIndex: 'priceChange',
139
140 width: '${pricechangeWidth}',
141 sortable: true,
142 renderer: 'renderChange'
143 }, {
144 text: '% Change',
145 dataIndex: 'priceChangePct',
146
147 width: '${percentChangeColumnWidth}',
148 sortable: true,
149 renderer: 'renderPercent'
150 }, {
151 text: 'Last Updated',
152 dataIndex: 'priceLastChange',
153
154 width: '${lastUpdatedColumnWidth}',
155 sortable: true,
156 formatter: 'date("m/d/Y")'
157 }, {
158 text: 'Rating',
159 dataIndex: 'rating',
160
161 width: '${ratingColumnWidth}',
162 sortable: true,
163 formatter: 'pick("A","B","C")'
164 }]
165 }, {
166 xtype: 'fieldset',
167 title: 'Company details',
168
169 columnWidth: '${formWidth}',
170 margin: '0 0 0 10',
171 layout: 'anchor',
172 defaultType: 'textfield',
173
174 items: [{
175 fieldLabel: 'Name',
176 bind: '{theCompany.name}'
177 }, {
178 fieldLabel: 'Price',
179 bind: '{theCompany.price}'
180 }, {
181 fieldLabel: '% Change',
182 bind: '{theCompany.priceChangePct}'
183 }, {
184 xtype: 'radiogroup',
185 fieldLabel: 'Rating',
186 bind: '{theCompany.rating}',
187
188 // Maps the value of this radiogroup to the child radio with matching
189 // inputValue.
190 simpleValue: true,
191 columns: 3,
192
193 items: [{
194 boxLabel: 'A',
195 inputValue: 0
196 }, {
197 boxLabel: 'B',
198 inputValue: 1
199 }, {
200 boxLabel: 'C',
201 inputValue: 2
202 }]
203 }, {
204 labelAlign: 'top',
205 xtype: 'datefield',
206 fieldLabel: 'Last Updated (Not editable)',
207 labelSeparator: '',
208 bind: '{theCompany.priceLastChange}',
209
210 // This field is only set when the price changes
211 // The Model rejects set changes.
212 readOnly: true
213 }]
214 }]
215});