extjs表单中动态添加items

来源:互联网 发布:ubuntu休眠设置 编辑:程序博客网 时间:2024/05/01 08:03
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();                }               }        ]
0 0
原创粉丝点击