`
java-mans
  • 浏览: 11458169 次
文章分类
社区版块
存档分类
最新评论

ExtJS笔记----FormPanel的使用

 
阅读更多

转载自:http://lucky16.iteye.com/blog/1490278

一、效果图
    先用美图勾引那些驻足观望之人:

二、代码讲解
注意代码中的EXT js引入路径, 需要根据你的实际情况进行引入,否者可能出现错误

Javascript代码收藏代码
  1. <html>
  2. <head>
  3. <title>系统登录</title>
  4. <metacharset="UTF-8"/>
  5. <linkrel="stylesheet"type="text/css"href="extjs/resources/css/ext-all.css"/>
  6. <style>
  7. </style>
  8. <scripttype="text/javascript"src="extjs/ext-base.js"></script>
  9. <scripttype="text/javascript"src="extjs/ext-all.js"></script>
  10. <scripttype="text/javascript"src="extjs/ext-lang-zh_CN.js"></script>
  11. </head>
  12. <body>
  13. <formid="form1"runat="server">
  14. <scripttype="text/javascript">
  15. Ext.onReady(function(){
  16. Ext.QuickTips.init();
  17. Ext.form.Field.prototype.msgTarget='side';
  18. varform1=newExt.FormPanel({
  19. layout:'form',
  20. collapsible:true,
  21. autoHeight:true,
  22. frame:true,
  23. renderTo:Ext.getBody(),
  24. title:'<centerstyle="curor:hand"onclick="window.location.reload();">表单控件</center>',
  25. style:'margin-left:auto;margin-right:auto;width:500px;margin-top:8px;',
  26. //设置标签对齐方式
  27. labelAlign:'right',
  28. //设置标签宽
  29. labelWidth:170,
  30. //设置按钮的对齐方式
  31. buttonAlign:'center',
  32. //默认元素属性设置
  33. defaults:{
  34. width:180
  35. },
  36. items:[{
  37. fieldLabel:'文本框控件',
  38. name:'TextBox',
  39. xtype:'textfield'
  40. //,readOnly:true//只读
  41. //,emptyText:'请输入数据'//为空时显示的文本,注意不是value
  42. },{
  43. fieldLabel:'只允许输入数字',
  44. name:'TextBoxNumber',
  45. xtype:'numberfield'
  46. //,allowDecimals:false//允许小数点
  47. //,allowNegative:false,//允许负数
  48. //,maxValue:1000//最大值
  49. //,minValue:0//最小值
  50. },{
  51. fieldLabel:'下拉框控件',
  52. name:'DropDownList',
  53. xtype:'combo',
  54. //mode:'local',
  55. displayField:"Name",
  56. //设置为选项的value的字段
  57. valueField:"Id",
  58. //是否可以输入,还是只能选择下拉框中的选项
  59. editable:false,
  60. typeAhead:true,
  61. //必须选择一项
  62. //forceSelection:true,
  63. //输入部分选项内容匹配的时候显示所有的选项
  64. triggerAction:'all',
  65. //selectOnFocus:true,
  66. //数据
  67. store:newExt.data.SimpleStore({
  68. fields:['Id','Name'],
  69. data:[[1,'男'],[0,'女']]
  70. })
  71. },{
  72. fieldLabel:'日历控件',
  73. xtype:'datefield',
  74. name:'DateControl',
  75. format:"Y-m-d",
  76. editable:false
  77. //,默认当前日期
  78. //value:newDate().dateFormat('Y-m-d')
  79. },{
  80. fieldLabel:'单选控件',
  81. xtype:'radiogroup',
  82. name:'Radios',
  83. items:[{
  84. name:'RadioItems',
  85. boxLabel:'选我',
  86. inputValue:'1',
  87. checked:true
  88. },{
  89. name:'RadioItems',
  90. boxLabel:'选我吧',
  91. inputValue:'0'
  92. }]
  93. },{
  94. fieldLabel:'复选控件',
  95. xtype:'checkboxgroup',
  96. name:'Checkboxs'
  97. //columns属性表示用2行来显示数据
  98. ,
  99. columns:2,
  100. items:[{
  101. name:'CheckboxItems',
  102. boxLabel:'香蕉',
  103. inputValue:'A'
  104. },{
  105. name:'CheckboxItems',
  106. boxLabel:'苹果',
  107. inputValue:'B'
  108. },{
  109. name:'CheckboxItems',
  110. boxLabel:'橘子',
  111. inputValue:'C'
  112. },{
  113. name:'CheckboxItems',
  114. boxLabel:'桃子',
  115. inputValue:'D'
  116. }]
  117. },{
  118. fieldLabel:'文本域控件',
  119. xtype:'textarea',
  120. value:'可以输好多字!',
  121. height:50
  122. },{
  123. fieldLabel:'时间控件',
  124. xtype:'timefield'
  125. //格式化输出默认为"g:iA"
  126. //"g:ia|g:iA|g:ia|g:iA|h:i|g:i|H:i|ga|ha|gA|ha|ga|gA|gi|hi|gia|hia|g|H"
  127. ,
  128. format:'H:i'
  129. //时间间隔(分钟)
  130. ,
  131. increment:60
  132. },{
  133. fieldLabel:'标签页',
  134. xtype:'fieldset',
  135. title:'标签页',
  136. autoHeight:true,
  137. items:[{
  138. xtype:'panel',
  139. title:'标签页中的面板',
  140. frame:true,
  141. height:50
  142. }]
  143. },{
  144. fieldLabel:'在线编辑器',
  145. xtype:'htmleditor',
  146. width:260,
  147. height:100
  148. //以下为默认选项,其他请参照源代码
  149. //,enableColors:false
  150. //,enableFormat:true
  151. //,enableFontSize:true
  152. //,enableAlignments:true
  153. //,enableLists:true
  154. //,enableSourceEdit:true
  155. //,enableLinks:true
  156. //,enableFont:true
  157. }],
  158. buttons:[{
  159. text:"保存",
  160. handler:function(){
  161. MsgInfo('保存');
  162. }
  163. },{
  164. text:"取消",
  165. handler:function(){
  166. form1.form.reset();
  167. }
  168. }]
  169. });
  170. functionMsgInfo(str_msg){
  171. Ext.MessageBox.show({
  172. title:'提示',
  173. msg:str_msg,
  174. width:400,
  175. icon:Ext.MessageBox.INFO,
  176. buttons:Ext.MessageBox.OK
  177. });
  178. }
  179. });
  180. </script>
  181. </form>
  182. </body>
  183. </html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics