Extjs4的FormPanel如何动态添加表单组件

{
                         columnWidth:0.25,
                         items:[{
                             columnWidth:0.25,
                             items:[{
                                 xtype: 'textfield' ,
                                 maxLength:50,
                                 width:150,
                                 name: 'Gzzk'
                             }]
                          }]
                     }]
                 },{
                     columnWidth:1,
                     layout: 'column' ,
                     style: 'padding-top:8px;padding-left:14' ,
                     layout: 'form' ,
                     labelWidth:70,
                     items:[{
                         anchor:  '45%' ,
                         allowBlank:  true ,
                         msgTarget:  'side' ,
                         xtype:  'fileuploadfield' ,
                         id:  'filepath' ,
                         name:  'filepath' ,
                         emptyText:  '请选择一个文件' ,
                         fieldLabel:  '上传文件' ,
                         buttonCfg: {
                             text:  '' ,
                             iconCls:  'upload-icon'
                         }
                     }] //itmes2 over
                 },{
                     columnWidth:1,
                     style: 'padding-top:8px;padding-left:14' ,
                     items:[{
                         xtype: 'button' ,
                         text: '点击生成下一行' ,
                         handler: function (){
                             
                             var  _panel =  this .ownerCt;
                             
                             var  _textfield =  new  Ext.form.TextField({
                                width:150 
                             });
                             
                             _panel.add(_textfield);
                         }
                     }]
                 }
             ] //items1 over
             ,buttons:[
                 {
                     id: 'btnOk' ,
                     text: '确  定' ,
                     handler: function ()
                     {
                         Ext.MessageBox.show
                         (
                             {
                                 msg:  '正在保存,请稍等...' ,
                                 progressText:  'Saving...' ,
                                 width:300,
                                 wait: true ,
                                 waitConfig: {interval:200},
                                 icon: 'download' ,
                                 animEl:  'saving'
                             }
                         );                        
                         fp.form.submit
                         (
                             {
                                 url: '../../MyAshx/Gcglb/add/gcglb_gcxxgl_sgjs.ashx?xmid=' +xmid,  
                                 method: 'post' ,
                                 success: function (form,action)
                                 {
                                     var  flag = action.result.success;
                                     if  (flag ==  true )
                                     {
                                         Ext.MessageBox.alert( '恭喜' , '添加信息成功!' );
                                         Datas.reload(); 
                                         newWin.destroy();
                                     }
                                 },
                                 failure: function ()
                                 {
                                     Ext.Msg.alert( '错误' , '服务器出现错误请稍后再试!' );
                                 }
                             }
                         );
                     }
                 },{
                     text: '关   闭' ,
                     handler: function ()
                     {                        
                         newWin.destroy();
                     }
                 }
             ]
         }
     );
     newWin =  new  Ext.Window
     (
         {
             layout: 'fit' ,
             resizeHandles: 'n s' ,
             resizable : true ,
             width:740,
             closable: false ,
             height:400,
             minWidth:740,
             frame: true ,
             minHeight:400,
             collapsible: false
             closeAction :  'hide' ,  
             autoScroll: true ,   
             plain :  false ,
             modal:  'true'
             title :  '添加技术人员动态信息' ,
             items : fp
         }
     );
     newWin.show();   
     
}

你可能感兴趣的:(EXT,JS4)