我简单的描述下:一个tabpanel有两个tab页,这个tabpanel显示出来,激活了tab 1但是没有激活tab 2,这个时候我点击提交往后台发送请求,结果tab 2上控件所承载的数据全部为空值,我们使用的是struts2+extjs,请问有什么方法解决能让tab 2的数据也能传到后台而不是空值。

解决方案 »

  1.   

    {
    xtype : 'tabpanel',
    id : 'dev',
    plain : true,
    height : 400 ,
    deferredRender: false,
    tabWidth : 120,
    activeTab: 0,
    width :20,
    autoWidth : true,
    defaults : {
      autoHeight : true,
      bodyStyle : 'padding:10px'
    },
    items : [{
    layout : 'tableform',
    title : '${action.getText("page.text.device.properties")}',
    baseCls : 'x-plain',
    defaults:{
    anchor:'93%'
    },
    labelAlign : 'right',
    layoutConfig:{
    columns:2
    },
    items : [{ 
    xtype : 'fieldset',
    title : '${action.getText("page.text.device.properties")}',
    layout : 'tableform',
    labelWidth : 90,
    style : 'padding-top:10px',
    labelAlign : 'right',
    layoutConfig : {
    columns : 1
    },
    defaults : {
    xtype : 'textfield',
    anchor : '90%',
    padding : 2
    },
    items:[{
    fieldLabel:'${action.getText("IMEI")}',
    name:'imei'
    },{
    fieldLabel:'${action.getText("MODEL")}',
            xtype: 'combo',
                store: new Ext.data.JsonStore({
                 url: '<@s.url action="devInfoAction!findAllDeviceInfo"/>',
                    totalProperty : 'total',
                    root : 'list',
                    successProperty : 'success',
                 fields : ['id', 'model', 'previewUrl'],
                 autoLoad : true
                }),
                mode: 'local',
                valueField: 'id',
                displayField: 'model',
                triggerAction: 'all',
                editable: false,
                hiddenName: 'devInfo.id',
                name : 'devInfo.id',
                listeners :{
         'select' : function(combo){
         var red = combo.store.getById(combo.getValue());
         Ext.getCmp('previewUrl').getEl().dom.src = red.data.previewUrl;
         }
    },
                allowBlank: false
    },{
       fieldLabel : '${action.getText("NAME")}',
       name : 'name'
    },{
           fieldLabel : '${action.getText("ASSET_CODE")}',
           name : 'assetCode'
    },{
           fieldLabel : '${action.getText("MSIN")}',
      id:'msin',
      name : 'msin'
    },{
           fieldLabel : '${action.getText("LOCATION")}',
      id:'location',
      name : 'location'
            },{
     fieldLabel:'${action.getText("HEALTH_STATUS")}',
     xtype : 'dictcombo',
     key:'Device.HealthStatus',
                  mode: 'local',
                 triggerAction: 'all',
                 editable: false,
                 hiddenName: 'healthStatus',
                 listeners : {
                  'render' : function(){
                  if(this.getValue() == "")
                  this.setValue(0);
                  }
                 },
         name:'healthStatus'
    }]},{ 
    xtype:'fieldset',
    layout:'tableform',
    title : '${action.getText("PREVIEW_URL")}',
    style:'padding-top:10px;padding-left:10px;',
    labelAlign:'right',
    defaults:{
    xtype:'textfield',
    anchor:'93%',
    itemCls:'noborder',
    padding:2
    },
    items:[{
    id : 'previewUrl',
    xtype:'box',
    autoEl : {
    tag : 'img',  
                src : '',
                style : 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);' 
    }
              },{
    xtype : 'hidden',
    hideLabel :true,
        name:'id'
          }]}]
       },{
       layout : 'tableform',
       title : '${action.getText("page.text.device.paraminfo")}',
       baseCls : 'x-plain',
       autoHeight : true,
       labelAlign : 'right',
       layoutConfig:{
    columns:1
    },
       items:[{ 
    xtype:'fieldset',
    layout:'tableform',
        title:'${action.getText("page.text.device.proparam")}',
    style:'padding-top:5px',
    labelAlign:'right',
    labelWidth : 90,
    layoutConfig:{
    columns:2
    },
    defaults:{
    xtype:'textfield',
    anchor:'88%',
    itemCls:'noborder',
    padding:2
    },
    items:[{
    fieldLabel:'${action.getText("ENABLED")}',
    xtype : 'dictcombo',
    key:'Common.Boolean',
                 mode: 'local',
                triggerAction: 'all',
                editable: false,
                hiddenName: 'enabled',
                listeners : {
                  'render' : function(){
                  if(this.getValue() == "")
                  this.setValue(1);
                  }
                 },
        name:'enabled'
    },{
    fieldLabel:'${action.getText("GSM_ENABLED")}',
    xtype : 'dictcombo',
    key:'Device.GsmEnabled',
                 mode: 'local',
                triggerAction: 'all',
                editable: false,
                hiddenName: 'gsmEnabled',
                allowBlank: false,
                listeners : {
                  'render' : function(){
                  if(this.getValue() == "")
                  this.setValue(1);
                  }
                 },
        name:'gsmEnabled'
    },{
             fieldLabel:'${action.getText("POSITION")}',
        id : 'position',
    name : 'position'
          },{
    fieldLabel:'${action.getText("PROXY")}',
            xtype: 'combo',
            id: 'proxy',
            autoScroll: false,
            allowBlank: false,
                store: new Ext.data.JsonStore({
                 url: '<@s.url action="proxyAction!findAllProxy"/>',
                    totalProperty : 'total',
                    root : 'list',
                    successProperty : 'success',
                 fields: ['id', 'ip'],
                 autoLoad : true
                }),
                mode: 'local',
                valueField: 'id',
                displayField: 'ip',
                triggerAction: 'all',
                editable: false,
                hiddenName: 'proxy.id',
                name : 'proxy.id',
                allowBlank: false
          },{
            fieldLabel:'${action.getText("HOME_DIR")}',
        name:'homeDir'
          },{
    fieldLabel:'${action.getText("ACCESS_MODE")}',
    xtype : 'dictcombo',
    key:'Device.AccessMode',
                 mode: 'local',
                triggerAction: 'all',
                editable: false,
                hiddenName: 'accessMode',
                allowBlank: false,
                listeners :{
                  'render' : function(){
                  if(this.getValue() == "")
                  this.setValue(2);
                  comFunc(this);
                  },
         'select' : comFunc
    },
        name:'accessMode'
     },{
            fieldLabel:'${action.getText("ABILITY")}',
        name:'ability'
          },{
            fieldLabel:'${action.getText("ABILITY_MAPPING")}',
        name:'abilityMapping'
          },{
            fieldLabel:'${action.getText("OUTPUT_MODE")}',
            colspan : 2,
            anchor : '94%',
        name:'outputMode'
          }]},
          { 
    xtype:'fieldset',
    layout:'tableform',
    id : 'softparam',
        title:'${action.getText("page.text.device.softparam")}',
    style:'padding-top:5px',
    labelAlign:'right',
    layoutConfig:{

          }]}]}]
          }这个是tabpanel的部分源码,看源码没多大的用,这个问题主要看思想。