/ext-4.1.0_b3/docs/source/Form.html

https://bitbucket.org/srogerf/javascript · HTML · 165 lines · 149 code · 16 blank · 0 comment · 0 complexity · f5615c5130d1c8ebb0deb0297131e974 MD5 · raw file

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-layout-container-Form'>/**
  19. </span> * This is a layout that will render form Fields, one under the other all stretched to the Container width.
  20. *
  21. * @example
  22. * Ext.create('Ext.Panel', {
  23. * width: 500,
  24. * height: 300,
  25. * title: &quot;FormLayout Panel&quot;,
  26. * layout: 'form',
  27. * renderTo: Ext.getBody(),
  28. * bodyPadding: 5,
  29. * defaultType: 'textfield',
  30. * items: [{
  31. * fieldLabel: 'First Name',
  32. * name: 'first',
  33. * allowBlank:false
  34. * },{
  35. * fieldLabel: 'Last Name',
  36. * name: 'last'
  37. * },{
  38. * fieldLabel: 'Company',
  39. * name: 'company'
  40. * }, {
  41. * fieldLabel: 'Email',
  42. * name: 'email',
  43. * vtype:'email'
  44. * }, {
  45. * fieldLabel: 'DOB',
  46. * name: 'dob',
  47. * xtype: 'datefield'
  48. * }, {
  49. * fieldLabel: 'Age',
  50. * name: 'age',
  51. * xtype: 'numberfield',
  52. * minValue: 0,
  53. * maxValue: 100
  54. * }, {
  55. * xtype: 'timefield',
  56. * fieldLabel: 'Time',
  57. * name: 'time',
  58. * minValue: '8:00am',
  59. * maxValue: '6:00pm'
  60. * }],
  61. * });
  62. *
  63. * Note that any configured {@link Ext.Component#padding padding} will be ignored on items within a Form layout.
  64. */
  65. Ext.define('Ext.layout.container.Form', {
  66. /* Begin Definitions */
  67. alias: 'layout.form',
  68. extend: 'Ext.layout.container.Auto',
  69. alternateClassName: 'Ext.layout.FormLayout',
  70. /* End Definitions */
  71. type: 'form',
  72. manageOverflow: 2,
  73. childEls: ['formTable'],
  74. renderTpl: [
  75. '&lt;table id=&quot;{ownerId}-formTable&quot; style=&quot;width:100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;',
  76. '{%this.renderBody(out,values)%}',
  77. '&lt;/table&gt;',
  78. '{%this.renderPadder(out,values)%}'
  79. ],
  80. calculate : function (ownerContext) {
  81. var me = this,
  82. containerSize = me.getContainerSize(ownerContext, true),
  83. tableWidth,
  84. childItems,
  85. i = 0, length;
  86. // Once we have been widthed, we can impose that width (in a non-dirty setting) upon all children at once
  87. if (containerSize.gotWidth) {
  88. this.callParent(arguments);
  89. tableWidth = me.formTable.dom.offsetWidth;
  90. childItems = ownerContext.childItems;
  91. for (length = childItems.length; i &lt; length; ++i) {
  92. childItems[i].setWidth(tableWidth, false);
  93. }
  94. } else {
  95. me.done = false;
  96. }
  97. },
  98. getRenderTarget: function() {
  99. return this.formTable;
  100. },
  101. getRenderTree: function() {
  102. var result = this.callParent(arguments),
  103. i = 0, len = result.length,
  104. prefix = Ext.baseCSSPrefix,
  105. children = '&lt;tr&gt;&lt;td class=&quot;' + prefix + 'form-item-pad&quot; colspan=&quot;3&quot;&gt;&lt;/td&gt;&lt;/tr&gt;',
  106. bodyCls = prefix + 'form-layout-tbody',
  107. item;
  108. for (; i &lt; len; i++) {
  109. item = result[i];
  110. if (item.tag &amp;&amp; item.tag == 'table') {
  111. item.tag = 'tbody';
  112. item.cls += ' ' + bodyCls;
  113. delete item.cellspacing;
  114. delete item.cellpadding;
  115. item.cn = children;
  116. } else {
  117. result[i] = {
  118. tag: 'tbody',
  119. cls: bodyCls,
  120. cn: {
  121. tag: 'tr',
  122. cn: {
  123. tag: 'td',
  124. colspan: 3,
  125. style: 'width:100%',
  126. cn: item
  127. }
  128. }
  129. };
  130. }
  131. }
  132. return result;
  133. },
  134. isValidParent: function(item, target, position) {
  135. return true;
  136. },
  137. isItemShrinkWrap: function(item) {
  138. return ((item.shrinkWrap === true) ? 3 : item.shrinkWrap||0) &amp; 2;
  139. },
  140. getItemSizePolicy: function(item) {
  141. return {
  142. setsWidth: 1,
  143. setsHeight: 0
  144. }
  145. }
  146. });
  147. </pre>
  148. </body>
  149. </html>