You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
8.1 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function() {
  16. Ext.QuickTips.init();
  17. var form = new Ext.form.FormPanel({
  18. renderTo: 'docbody',
  19. title : 'Composite Fields',
  20. autoHeight: true,
  21. width : 600,
  22. bodyStyle: 'padding: 5px',
  23. defaults: {
  24. anchor: '0'
  25. },
  26. items : [
  27. {
  28. xtype : 'textfield',
  29. name : 'email',
  30. fieldLabel: 'Email Address',
  31. anchor : '-20'
  32. },
  33. {
  34. xtype: 'compositefield',
  35. fieldLabel: 'Date Range',
  36. msgTarget : 'side',
  37. anchor : '-20',
  38. defaults: {
  39. flex: 1
  40. },
  41. items: [
  42. {
  43. xtype: 'datefield',
  44. name : 'startDate'
  45. },
  46. {
  47. xtype: 'datefield',
  48. name : 'endDate'
  49. }
  50. ]
  51. },
  52. {
  53. xtype: 'fieldset',
  54. title: 'Details',
  55. collapsible: true,
  56. items: [
  57. {
  58. xtype: 'compositefield',
  59. fieldLabel: 'Phone',
  60. // anchor : '-20',
  61. // anchor : null,
  62. msgTarget: 'under',
  63. items: [
  64. {xtype: 'displayfield', value: '('},
  65. {xtype: 'textfield', name: 'phone-1', width: 29, allowBlank: false},
  66. {xtype: 'displayfield', value: ')'},
  67. {xtype: 'textfield', name: 'phone-2', width: 29, allowBlank: false, margins: '0 5 0 0'},
  68. {xtype: 'textfield', name: 'phone-3', width: 48, allowBlank: false}
  69. ]
  70. },
  71. {
  72. xtype: 'compositefield',
  73. fieldLabel: 'Time worked',
  74. combineErrors: false,
  75. items: [
  76. {
  77. name : 'hours',
  78. xtype: 'numberfield',
  79. width: 48,
  80. allowBlank: false
  81. },
  82. {
  83. xtype: 'displayfield',
  84. value: 'hours'
  85. },
  86. {
  87. name : 'minutes',
  88. xtype: 'numberfield',
  89. width: 48,
  90. allowBlank: false
  91. },
  92. {
  93. xtype: 'displayfield',
  94. value: 'mins'
  95. }
  96. ]
  97. },
  98. {
  99. xtype : 'compositefield',
  100. anchor: '-20',
  101. msgTarget: 'side',
  102. fieldLabel: 'Full Name',
  103. items : [
  104. {
  105. //the width of this field in the HBox layout is set directly
  106. //the other 2 items are given flex: 1, so will share the rest of the space
  107. width: 50,
  108. xtype: 'combo',
  109. mode: 'local',
  110. value: 'mrs',
  111. triggerAction: 'all',
  112. forceSelection: true,
  113. editable: false,
  114. fieldLabel: 'Title',
  115. name: 'title',
  116. hiddenName: 'title',
  117. displayField: 'name',
  118. valueField: 'value',
  119. store: new Ext.data.JsonStore({
  120. fields : ['name', 'value'],
  121. data : [
  122. {name : 'Mr', value: 'mr'},
  123. {name : 'Mrs', value: 'mrs'},
  124. {name : 'Miss', value: 'miss'}
  125. ]
  126. })
  127. },
  128. {
  129. xtype: 'textfield',
  130. flex : 1,
  131. name : 'firstName',
  132. fieldLabel: 'First',
  133. allowBlank: false
  134. },
  135. {
  136. xtype: 'textfield',
  137. flex : 1,
  138. name : 'lastName',
  139. fieldLabel: 'Last',
  140. allowBlank: false
  141. }
  142. ]
  143. }
  144. ]
  145. }
  146. ],
  147. buttons: [
  148. {
  149. text : 'Load test data',
  150. handler: function() {
  151. var Record = Ext.data.Record.create([
  152. {name: 'email', type: 'string'},
  153. {name: 'title', type: 'string'},
  154. {name: 'firstName', type: 'string'},
  155. {name: 'lastName', type: 'string'},
  156. {name: 'phone-1', type: 'string'},
  157. {name: 'phone-2', type: 'string'},
  158. {name: 'phone-3', type: 'string'},
  159. {name: 'hours', type: 'number'},
  160. {name: 'minutes', type: 'number'},
  161. {name: 'startDate', type: 'date'},
  162. {name: 'endDate', type: 'date'}
  163. ]);
  164. form.form.loadRecord(new Record({
  165. 'email' : 'ed@extjs.com',
  166. 'title' : 'mr',
  167. 'firstName': 'Abraham',
  168. 'lastName' : 'Elias',
  169. 'startDate': '01/10/2003',
  170. 'endDate' : '12/11/2009',
  171. 'phone-1' : '555',
  172. 'phone-2' : '123',
  173. 'phone-3' : '4567',
  174. 'hours' : 7,
  175. 'minutes' : 15
  176. }));
  177. }
  178. },
  179. {
  180. text : 'Save',
  181. handler: function() {
  182. if (form.form.isValid()) {
  183. var s = '';
  184. Ext.iterate(form.form.getValues(), function(key, value) {
  185. s += String.format("{0} = {1}<br />", key, value);
  186. }, this);
  187. Ext.example.msg('Form Values', s);
  188. }
  189. }
  190. },
  191. {
  192. text : 'Reset',
  193. handler: function() {
  194. form.form.reset();
  195. }
  196. }
  197. ]
  198. });
  199. });