]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * The FieldContainer\'s child items are arranged like in any other container, using the\r | |
3 | * layout configuration property. In this example, each FieldContainer is set to use an\r | |
4 | * HBox layout.\r | |
5 | *\r | |
6 | * FieldContainers can be configured with the combineErrors option, which combines errors\r | |
7 | * from the sub fields and presents them at the container level. In this example the\r | |
8 | * Availability, Phone and Full Name items have this option enabled, and the Time worked\r | |
9 | * item does not.\r | |
10 | */\r | |
11 | Ext.define('KitchenSink.view.form.FieldContainer', {\r | |
12 | extend: 'Ext.form.Panel',\r | |
13 | xtype: 'form-fieldcontainer',\r | |
14 | controller: 'form-fieldcontainer',\r | |
15 | \r | |
16 | //<example>\r | |
17 | requires: [\r | |
18 | 'KitchenSink.model.PartTimeEmployee',\r | |
19 | 'KitchenSink.view.form.FieldContainerController'\r | |
20 | ],\r | |
21 | \r | |
22 | exampleTitle: 'Field Container',\r | |
23 | otherContent: [{\r | |
24 | type: 'Model',\r | |
25 | path: 'classic/samples/model/PartTimeEmployee.js'\r | |
26 | }, {\r | |
27 | type: 'ViewController',\r | |
28 | path: 'classic/samples/view/form/FieldContainerController.js'\r | |
29 | }],\r | |
30 | //</example>\r | |
31 | \r | |
32 | title: 'Employee Information',\r | |
33 | width: 600,\r | |
34 | bodyPadding: 10,\r | |
35 | defaults: {\r | |
36 | anchor: '100%',\r | |
37 | labelWidth: 100\r | |
38 | },\r | |
39 | items: [{\r | |
40 | xtype: 'textfield',\r | |
41 | name: 'email',\r | |
42 | fieldLabel: 'Email Address',\r | |
43 | vtype: 'email',\r | |
44 | msgTarget: 'side',\r | |
45 | allowBlank: false\r | |
46 | }, {\r | |
47 | xtype: 'fieldcontainer',\r | |
48 | fieldLabel: 'Availability',\r | |
49 | combineErrors: true,\r | |
50 | msgTarget : 'side',\r | |
51 | layout: 'hbox',\r | |
52 | defaults: {\r | |
53 | flex: 1,\r | |
54 | hideLabel: true\r | |
55 | },\r | |
56 | items: [{\r | |
57 | xtype: 'datefield',\r | |
58 | name: 'startDate',\r | |
59 | fieldLabel: 'Start',\r | |
60 | margin: '0 5 0 0',\r | |
61 | allowBlank: false\r | |
62 | }, {\r | |
63 | xtype : 'datefield',\r | |
64 | name : 'endDate',\r | |
65 | fieldLabel: 'End',\r | |
66 | allowBlank: false\r | |
67 | }]\r | |
68 | }, {\r | |
69 | xtype: 'fieldset',\r | |
70 | title: 'Details',\r | |
71 | collapsible: true,\r | |
72 | defaults: {\r | |
73 | labelWidth: 90,\r | |
74 | anchor: '100%',\r | |
75 | layout: 'hbox'\r | |
76 | },\r | |
77 | items: [{\r | |
78 | xtype: 'fieldcontainer',\r | |
79 | fieldLabel: 'Phone',\r | |
80 | combineErrors: true,\r | |
81 | msgTarget: 'under',\r | |
82 | defaults: {\r | |
83 | hideLabel: true,\r | |
84 | enforceMaxLength: true,\r | |
85 | maskRe: /[0-9.]/\r | |
86 | },\r | |
87 | items: [\r | |
88 | {xtype: 'displayfield', value: '(', margin: '0 2 0 0'},\r | |
89 | {xtype: 'textfield', fieldLabel: 'Phone 1', name: 'phone-1', width: 45, allowBlank: false, maxLength: 3},\r | |
90 | {xtype: 'displayfield', value: ')', margin: '0 5 0 2'},\r | |
91 | {xtype: 'textfield', fieldLabel: 'Phone 2', name: 'phone-2', width: 45, allowBlank: false, margin: '0 5 0 0', maxLength: 3},\r | |
92 | {xtype: 'displayfield', value: '-'},\r | |
93 | {xtype: 'textfield', fieldLabel: 'Phone 3', name: 'phone-3', width: 60, allowBlank: false, margin: '0 0 0 5', maxLength: 4}\r | |
94 | ]\r | |
95 | }, {\r | |
96 | xtype: 'fieldcontainer',\r | |
97 | fieldLabel: 'Time worked',\r | |
98 | combineErrors: false,\r | |
99 | defaults: {\r | |
100 | hideLabel: true,\r | |
101 | margin: '0 5 0 0'\r | |
102 | },\r | |
103 | items: [{\r | |
104 | name : 'hours',\r | |
105 | xtype: 'numberfield',\r | |
106 | minValue: 0,\r | |
107 | width: 95,\r | |
108 | allowBlank: false\r | |
109 | }, {\r | |
110 | xtype: 'displayfield',\r | |
111 | value: 'hours'\r | |
112 | }, {\r | |
113 | name : 'minutes',\r | |
114 | xtype: 'numberfield',\r | |
115 | minValue: 0,\r | |
116 | width: 95,\r | |
117 | allowBlank: false\r | |
118 | }, {\r | |
119 | xtype: 'displayfield',\r | |
120 | value: 'mins'\r | |
121 | }]\r | |
122 | }, {\r | |
123 | xtype : 'fieldcontainer',\r | |
124 | combineErrors: true,\r | |
125 | msgTarget: 'side',\r | |
126 | fieldLabel: 'Full Name',\r | |
127 | defaults: {\r | |
128 | hideLabel: true,\r | |
129 | margin: '0 5 0 0'\r | |
130 | },\r | |
131 | items: [{\r | |
132 | //the width of this field in the HBox layout is set directly\r | |
133 | //the other 2 items are given flex: 1, so will share the rest of the space\r | |
134 | width: 75,\r | |
135 | xtype: 'combo',\r | |
136 | queryMode: 'local',\r | |
137 | value: 'mrs',\r | |
138 | triggerAction: 'all',\r | |
139 | forceSelection: true,\r | |
140 | editable: false,\r | |
141 | fieldLabel: 'Title',\r | |
142 | name: 'title',\r | |
143 | displayField: 'name',\r | |
144 | valueField: 'value',\r | |
145 | store: {\r | |
146 | fields: ['name', 'value'],\r | |
147 | data: [\r | |
148 | {name : 'Mr', value: 'mr'},\r | |
149 | {name : 'Mrs', value: 'mrs'},\r | |
150 | {name : 'Miss', value: 'miss'}\r | |
151 | ]\r | |
152 | }\r | |
153 | }, {\r | |
154 | xtype: 'textfield',\r | |
155 | flex : 1,\r | |
156 | name : 'firstName',\r | |
157 | fieldLabel: 'First',\r | |
158 | allowBlank: false\r | |
159 | }, {\r | |
160 | xtype: 'textfield',\r | |
161 | flex : 1,\r | |
162 | name : 'lastName',\r | |
163 | fieldLabel: 'Last',\r | |
164 | allowBlank: false\r | |
165 | }]\r | |
166 | }]\r | |
167 | }],\r | |
168 | \r | |
169 | buttons: [{\r | |
170 | text : 'Load test data',\r | |
171 | handler: 'onLoadClick'\r | |
172 | }, {\r | |
173 | text : 'Save',\r | |
174 | handler: 'onSaveClick'\r | |
175 | }, {\r | |
176 | text : 'Reset',\r | |
177 | handler: 'onResetClick'\r | |
178 | }]\r | |
179 | }); |