extjs表单中动态添加items

items:[
            var exceptionNumber = 1;
            var exceptionHandling =new String;
       {
           xtype: 'fieldset',
           title: '异常处理',
          id:'exceptionHand',
          defaultType: 'textfield',
          width:400,                          
          items:[
              {

                xtype:"button",
                text:"增加异常情况",
                handler : function() {
                exceptionNumber++;
                var exceptionForm = Ext.getCmp("exceptionHand");
                var configItem=[{
                xtype:'fieldcontainer',
                layout:'hbox',
                    items:[
                            {
                                xtype:'textfield',
                                labelAlign:'top',
                                id:'exceptionContex'+exceptionNumber,
                                name: 'exceptionContex'+exceptionNumber,                                
                                fieldLabel: '第'+exceptionNumber+'条异常内容',

                            },
                            {
                                   xtype:'textfield',
                                   labelAlign:'top',
                                   id:'solvingMethod'+exceptionNumber,             
                                   name: 'solvingMethod'+exceptionNumber,                               
                                   fieldLabel: '处理方式',

                            }

                          ]
                       }];
                                      exceptionForm.add(configItem[0]);
                                      exceptionForm.doLayout();
                                      }
            },
            {
                xtype:'fieldcontainer',
                layout:'hbox',
                labelAlign:'top',
                items:[
                       {
                         xtype:'textfield',
                         labelAlign:'top',
                         id:'exceptionContex1',
                         name: 'exceptionContex1',                              
                         fieldLabel: '第1条异常内容',
                       },
                      {
                         xtype:'textfield',
                         labelAlign:'top',
                         id:'solvingMethod1',
                         name: 'solvingMethod1',                                
                         fieldLabel: '处理方式',
                      }
                       ]
            }
          ]
},
buttons:[

          {
            text:"添加",
            handler:function(){
                    exceptionHandling ="{"; 
                    for(var i=1;i<=exceptionNumber;i++){
                    exceptionValue = Ext.getCmp('exceptionContex'+i).getValue();
                    solveMethod = Ext.getCmp('solvingMethod'+i).getValue();
                    exceptionHandling = exceptionHandling+'"'+exceptionValue+
                    '":"'+solveMethod+'",';
                    if(i==exceptionNumber){
                        exceptionHandling = exceptionHandling.substring(0,(exceptionHandling.length-1));
                    }
                 }
                         exceptionHandling = exceptionHandling + "}";

                           alert(exceptionHandling);
                               form.getForm().submit({
                                   params:{'testIFCObject.exceptionHandling':exceptionHandling},
                                   url:"TestIFCObjectAdd.action",
                                   waitMsg:"请稍等,正在添加",
                                   success:function(form,action){
                                    Ext.MessageBox.alert("提示信息","添加成功");
                                    store.reload();
                                    win.close(this);                                     
                                   },
                                    failure:function(form,action){
                                            Ext.MessageBox.alert("提示信息",action.result.msg);                                         
                                        }
                                });

                                }
                                   },
              {
                text:"重置",handler:function(){
                form.getForm().reset();
                }
               }
        ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值