Web Interface For Lite Argus Control modules
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.

198 lines
7.6 KiB

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