3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 'Ext.layout.container.Column',
18 'Ext.window.MessageBox',
19 'Ext.fx.target.Element'
22 Ext.onReady(function(){
25 /*====================================================================
26 * Individual checkbox/radio examples
27 *====================================================================*/
29 // Using checkbox/radio groups will generally be more convenient and flexible than
30 // using individual checkbox and radio controls, but this shows that you can
31 // certainly do so if you only have a single control at a time.
39 title: 'Individual Checkboxes',
40 defaultType: 'checkbox', // each item will be a checkbox
49 fieldLabel: 'Alignment Test'
51 fieldLabel: 'Favorite Animals',
53 name: 'fav-animal-dog',
57 name: 'fav-animal-cat',
62 name: 'fav-animal-monkey',
71 title: 'Individual Radios',
72 defaultType: 'radio', // each item will be a radio button
81 fieldLabel: 'Alignment Test'
84 fieldLabel: 'Favorite Color',
103 /*====================================================================
105 *====================================================================*/
108 title: 'Checkbox Groups (initially collapsed)',
112 labelStyle: 'padding-left:4px;'
119 fieldLabel: 'Alignment Test'
121 // Use the default, automatic layout to distribute the controls evenly
122 // across a single row
123 xtype: 'checkboxgroup',
124 fieldLabel: 'Auto Layout',
125 cls: 'x-check-group-alt',
127 {boxLabel: 'Item 1', name: 'cb-auto-1'},
128 {boxLabel: 'Item 2', name: 'cb-auto-2', checked: true},
129 {boxLabel: 'Item 3', name: 'cb-auto-3'},
130 {boxLabel: 'Item 4', name: 'cb-auto-4'},
131 {boxLabel: 'Item 5', name: 'cb-auto-5'}
134 xtype: 'checkboxgroup',
135 fieldLabel: 'Single Column',
136 // Put all controls in a single column with width 100%
139 {boxLabel: 'Item 1', name: 'cb-col-1'},
140 {boxLabel: 'Item 2', name: 'cb-col-2', checked: true},
141 {boxLabel: 'Item 3', name: 'cb-col-3'}
144 xtype: 'checkboxgroup',
145 fieldLabel: 'Multi-Column (horizontal)',
146 cls: 'x-check-group-alt',
147 // Distribute controls across 3 even columns, filling each row
148 // from left to right before starting the next row
151 {boxLabel: 'Item 1', name: 'cb-horiz-1'},
152 {boxLabel: 'Item 2', name: 'cb-horiz-2', checked: true},
153 {boxLabel: 'Item 3', name: 'cb-horiz-3'},
154 {boxLabel: 'Item 4', name: 'cb-horiz-4'},
155 {boxLabel: 'Item 5', name: 'cb-horiz-5'}
158 xtype: 'checkboxgroup',
159 fieldLabel: 'Multi-Column (vertical)',
160 // Distribute controls across 3 even columns, filling each column
161 // from top to bottom before starting the next column
165 {boxLabel: 'Item 1', name: 'cb-vert-1'},
166 {boxLabel: 'Item 2', name: 'cb-vert-2', checked: true},
167 {boxLabel: 'Item 3', name: 'cb-vert-3'},
168 {boxLabel: 'Item 4', name: 'cb-vert-4'},
169 {boxLabel: 'Item 5', name: 'cb-vert-5'}
172 xtype: 'checkboxgroup',
173 fieldLabel: 'Multi-Column<br />(custom widths)',
174 cls: 'x-check-group-alt',
175 // Specify exact column widths (could also include float values for %)
179 {boxLabel: 'Item 1', name: 'cb-custwidth', inputValue: 1},
180 {boxLabel: 'Item 2', name: 'cb-custwidth', inputValue: 2, checked: true},
181 {boxLabel: 'Item 3', name: 'cb-custwidth', inputValue: 3},
182 {boxLabel: 'Item 4', name: 'cb-custwidth', inputValue: 4},
183 {boxLabel: 'Item 5', name: 'cb-custwidth', inputValue: 5}
186 xtype: 'checkboxgroup',
187 fieldLabel: 'Custom Layout<br />(w/ validation)',
190 autoFitErrors: false,
192 // You can change the 'layout' to anything you want, and include any nested
193 // container structure, for complete layout control. In this example we only
194 // want one item in the middle column, which would not be possible using the
195 // default 'checkboxgroup' layout's columns config. We also want to put
196 // headings at the top of each column.
198 defaultType: 'container',
202 {xtype: 'component', html: 'Heading 1', cls:'x-form-check-group-label'},
203 {xtype: 'checkboxfield', boxLabel: 'Item 1', name: 'cb-cust-1'},
204 {xtype: 'checkboxfield', boxLabel: 'Item 2', name: 'cb-cust-2'}
209 {xtype: 'component', html: 'Heading 2', cls:'x-form-check-group-label'},
210 {xtype: 'checkboxfield', boxLabel: 'A long item just for fun', name: 'cb-cust-3'}
215 {xtype: 'component', html: 'Heading 3', cls:'x-form-check-group-label'},
216 {xtype: 'checkboxfield', boxLabel: 'Item 4', name: 'cb-cust-4'},
217 {xtype: 'checkboxfield', boxLabel: 'Item 5', name: 'cb-cust-5'}
223 /*====================================================================
224 * RadioGroup examples
225 *====================================================================*/
226 // NOTE: These radio examples use the exact same options as the checkbox ones
227 // above, so the comments will not be repeated. Please see comments above for
228 // additional explanation on some config options.
232 title: 'Radio Groups',
236 labelStyle: 'padding-left:4px;'
242 fieldLabel: 'Alignment Test'
245 fieldLabel: 'Auto Layout',
246 cls: 'x-check-group-alt',
248 {boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},
249 {boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2, checked: true},
250 {boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},
251 {boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},
252 {boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}
256 fieldLabel: 'Single Column',
259 {boxLabel: 'Item 1', name: 'rb-col', inputValue: 1},
260 {boxLabel: 'Item 2', name: 'rb-col', inputValue: 2, checked: true},
261 {boxLabel: 'Item 3', name: 'rb-col', inputValue: 3}
265 fieldLabel: 'Multi-Column (horizontal)',
266 cls: 'x-check-group-alt',
269 {boxLabel: 'Item 1', name: 'rb-horiz-1', inputValue: 1},
270 {boxLabel: 'Item 2', name: 'rb-horiz-1', inputValue: 2, checked: true},
271 {boxLabel: 'Item 3', name: 'rb-horiz-1', inputValue: 3},
272 {boxLabel: 'Item 1', name: 'rb-horiz-2', inputValue: 1, checked: true},
273 {boxLabel: 'Item 2', name: 'rb-horiz-2', inputValue: 2}
277 fieldLabel: 'Multi-Column (vertical)',
281 {boxLabel: 'Item 1', name: 'rb-vert', inputValue: 1},
282 {boxLabel: 'Item 2', name: 'rb-vert', inputValue: 2, checked: true},
283 {boxLabel: 'Item 3', name: 'rb-vert', inputValue: 3},
284 {boxLabel: 'Item 4', name: 'rb-vert', inputValue: 4},
285 {boxLabel: 'Item 5', name: 'rb-vert', inputValue: 5}
289 fieldLabel: 'Multi-Column<br />(custom widths)',
290 cls: 'x-check-group-alt',
294 {boxLabel: 'Item 1', name: 'rb-custwidth', inputValue: 1},
295 {boxLabel: 'Item 2', name: 'rb-custwidth', inputValue: 2, checked: true},
296 {boxLabel: 'Item 3', name: 'rb-custwidth', inputValue: 3},
297 {boxLabel: 'Item 4', name: 'rb-custwidth', inputValue: 4},
298 {boxLabel: 'Item 5', name: 'rb-custwidth', inputValue: 5}
302 fieldLabel: 'Custom Layout<br />(w/ validation)',
305 autoFitErrors: false,
308 defaultType: 'container',
312 {xtype: 'component', html: 'Heading 1', cls:'x-form-check-group-label'},
313 {xtype: 'radiofield', boxLabel: 'Item 1', name: 'rb-cust', inputValue: 1},
314 {xtype: 'radiofield', boxLabel: 'Item 2', name: 'rb-cust', inputValue: 2}
319 {xtype: 'component', html: 'Heading 2', cls:'x-form-check-group-label'},
320 {xtype: 'radiofield', boxLabel: 'A long item just for fun', name: 'rb-cust', inputValue: 3}
325 {xtype: 'component', html: 'Heading 3', cls:'x-form-check-group-label'},
326 {xtype: 'radiofield', boxLabel: 'Item 4', name: 'rb-cust', inputValue: 4},
327 {xtype: 'radiofield', boxLabel: 'Item 5', name: 'rb-cust', inputValue: 5}
334 // combine all that into one huge form
335 var fp = Ext.create('Ext.FormPanel', {
336 title: 'Check/Radio Groups Example',
352 if(fp.getForm().isValid()){
353 Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+
354 fp.getForm().getValues(true).replace(/&/g,', '));
360 fp.getForm().reset();