3 'Ext.layout.container.Column',
4 'Ext.window.MessageBox',
5 'Ext.fx.target.Element'
8 Ext.onReady(function(){
11 /*====================================================================
12 * Individual checkbox/radio examples
13 *====================================================================*/
15 // Using checkbox/radio groups will generally be more convenient and flexible than
16 // using individual checkbox and radio controls, but this shows that you can
17 // certainly do so if you only have a single control at a time.
25 title: 'Individual Checkboxes',
26 defaultType: 'checkbox', // each item will be a checkbox
35 fieldLabel: 'Alignment Test'
37 fieldLabel: 'Favorite Animals',
39 name: 'fav-animal-dog',
43 name: 'fav-animal-cat',
48 name: 'fav-animal-monkey',
57 title: 'Individual Radios',
58 defaultType: 'radio', // each item will be a radio button
67 fieldLabel: 'Alignment Test'
70 fieldLabel: 'Favorite Color',
89 /*====================================================================
91 *====================================================================*/
94 title: 'Checkbox Groups (initially collapsed)',
98 labelStyle: 'padding-left:4px;'
105 fieldLabel: 'Alignment Test'
107 // Use the default, automatic layout to distribute the controls evenly
108 // across a single row
109 xtype: 'checkboxgroup',
110 fieldLabel: 'Auto Layout',
111 cls: 'x-check-group-alt',
113 {boxLabel: 'Item 1', name: 'cb-auto-1'},
114 {boxLabel: 'Item 2', name: 'cb-auto-2', checked: true},
115 {boxLabel: 'Item 3', name: 'cb-auto-3'},
116 {boxLabel: 'Item 4', name: 'cb-auto-4'},
117 {boxLabel: 'Item 5', name: 'cb-auto-5'}
120 xtype: 'checkboxgroup',
121 fieldLabel: 'Single Column',
122 // Put all controls in a single column with width 100%
125 {boxLabel: 'Item 1', name: 'cb-col-1'},
126 {boxLabel: 'Item 2', name: 'cb-col-2', checked: true},
127 {boxLabel: 'Item 3', name: 'cb-col-3'}
130 xtype: 'checkboxgroup',
131 fieldLabel: 'Multi-Column (horizontal)',
132 cls: 'x-check-group-alt',
133 // Distribute controls across 3 even columns, filling each row
134 // from left to right before starting the next row
137 {boxLabel: 'Item 1', name: 'cb-horiz-1'},
138 {boxLabel: 'Item 2', name: 'cb-horiz-2', checked: true},
139 {boxLabel: 'Item 3', name: 'cb-horiz-3'},
140 {boxLabel: 'Item 4', name: 'cb-horiz-4'},
141 {boxLabel: 'Item 5', name: 'cb-horiz-5'}
144 xtype: 'checkboxgroup',
145 fieldLabel: 'Multi-Column (vertical)',
146 // Distribute controls across 3 even columns, filling each column
147 // from top to bottom before starting the next column
151 {boxLabel: 'Item 1', name: 'cb-vert-1'},
152 {boxLabel: 'Item 2', name: 'cb-vert-2', checked: true},
153 {boxLabel: 'Item 3', name: 'cb-vert-3'},
154 {boxLabel: 'Item 4', name: 'cb-vert-4'},
155 {boxLabel: 'Item 5', name: 'cb-vert-5'}
158 xtype: 'checkboxgroup',
159 fieldLabel: 'Multi-Column<br />(custom widths)',
160 cls: 'x-check-group-alt',
161 // Specify exact column widths (could also include float values for %)
165 {boxLabel: 'Item 1', name: 'cb-custwidth', inputValue: 1},
166 {boxLabel: 'Item 2', name: 'cb-custwidth', inputValue: 2, checked: true},
167 {boxLabel: 'Item 3', name: 'cb-custwidth', inputValue: 3},
168 {boxLabel: 'Item 4', name: 'cb-custwidth', inputValue: 4},
169 {boxLabel: 'Item 5', name: 'cb-custwidth', inputValue: 5}
172 xtype: 'checkboxgroup',
173 fieldLabel: 'Custom Layout<br />(w/ validation)',
176 autoFitErrors: false,
178 // You can change the 'layout' to anything you want, and include any nested
179 // container structure, for complete layout control. In this example we only
180 // want one item in the middle column, which would not be possible using the
181 // default 'checkboxgroup' layout's columns config. We also want to put
182 // headings at the top of each column.
184 defaultType: 'container',
188 {xtype: 'component', html: 'Heading 1', cls:'x-form-check-group-label'},
189 {xtype: 'checkboxfield', boxLabel: 'Item 1', name: 'cb-cust-1'},
190 {xtype: 'checkboxfield', boxLabel: 'Item 2', name: 'cb-cust-2'}
195 {xtype: 'component', html: 'Heading 2', cls:'x-form-check-group-label'},
196 {xtype: 'checkboxfield', boxLabel: 'A long item just for fun', name: 'cb-cust-3'}
201 {xtype: 'component', html: 'Heading 3', cls:'x-form-check-group-label'},
202 {xtype: 'checkboxfield', boxLabel: 'Item 4', name: 'cb-cust-4'},
203 {xtype: 'checkboxfield', boxLabel: 'Item 5', name: 'cb-cust-5'}
209 /*====================================================================
210 * RadioGroup examples
211 *====================================================================*/
212 // NOTE: These radio examples use the exact same options as the checkbox ones
213 // above, so the comments will not be repeated. Please see comments above for
214 // additional explanation on some config options.
218 title: 'Radio Groups',
222 labelStyle: 'padding-left:4px;'
228 fieldLabel: 'Alignment Test'
231 fieldLabel: 'Auto Layout',
232 cls: 'x-check-group-alt',
234 {boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},
235 {boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2, checked: true},
236 {boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},
237 {boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},
238 {boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}
242 fieldLabel: 'Single Column',
245 {boxLabel: 'Item 1', name: 'rb-col', inputValue: 1},
246 {boxLabel: 'Item 2', name: 'rb-col', inputValue: 2, checked: true},
247 {boxLabel: 'Item 3', name: 'rb-col', inputValue: 3}
251 fieldLabel: 'Multi-Column (horizontal)',
252 cls: 'x-check-group-alt',
255 {boxLabel: 'Item 1', name: 'rb-horiz-1', inputValue: 1},
256 {boxLabel: 'Item 2', name: 'rb-horiz-1', inputValue: 2, checked: true},
257 {boxLabel: 'Item 3', name: 'rb-horiz-1', inputValue: 3},
258 {boxLabel: 'Item 1', name: 'rb-horiz-2', inputValue: 1, checked: true},
259 {boxLabel: 'Item 2', name: 'rb-horiz-2', inputValue: 2}
263 fieldLabel: 'Multi-Column (vertical)',
267 {boxLabel: 'Item 1', name: 'rb-vert', inputValue: 1},
268 {boxLabel: 'Item 2', name: 'rb-vert', inputValue: 2, checked: true},
269 {boxLabel: 'Item 3', name: 'rb-vert', inputValue: 3},
270 {boxLabel: 'Item 4', name: 'rb-vert', inputValue: 4},
271 {boxLabel: 'Item 5', name: 'rb-vert', inputValue: 5}
275 fieldLabel: 'Multi-Column<br />(custom widths)',
276 cls: 'x-check-group-alt',
280 {boxLabel: 'Item 1', name: 'rb-custwidth', inputValue: 1},
281 {boxLabel: 'Item 2', name: 'rb-custwidth', inputValue: 2, checked: true},
282 {boxLabel: 'Item 3', name: 'rb-custwidth', inputValue: 3},
283 {boxLabel: 'Item 4', name: 'rb-custwidth', inputValue: 4},
284 {boxLabel: 'Item 5', name: 'rb-custwidth', inputValue: 5}
288 fieldLabel: 'Custom Layout<br />(w/ validation)',
291 autoFitErrors: false,
294 defaultType: 'container',
298 {xtype: 'component', html: 'Heading 1', cls:'x-form-check-group-label'},
299 {xtype: 'radiofield', boxLabel: 'Item 1', name: 'rb-cust', inputValue: 1},
300 {xtype: 'radiofield', boxLabel: 'Item 2', name: 'rb-cust', inputValue: 2}
305 {xtype: 'component', html: 'Heading 2', cls:'x-form-check-group-label'},
306 {xtype: 'radiofield', boxLabel: 'A long item just for fun', name: 'rb-cust', inputValue: 3}
311 {xtype: 'component', html: 'Heading 3', cls:'x-form-check-group-label'},
312 {xtype: 'radiofield', boxLabel: 'Item 4', name: 'rb-cust', inputValue: 4},
313 {xtype: 'radiofield', boxLabel: 'Item 5', name: 'rb-cust', inputValue: 5}
320 // combine all that into one huge form
321 var fp = Ext.create('Ext.FormPanel', {
322 title: 'Check/Radio Groups Example',
338 if(fp.getForm().isValid()){
339 Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+
340 fp.getForm().getValues(true).replace(/&/g,', '));
346 fp.getForm().reset();