cartonwang
2010-06-08 15:01
浏览 273

EXTJS2.0,项目中增加一个简单需求,新加一个下拉框选中数据后显示在原有的文本域中

小弟初时EXTJS,项目中碰到一个小问题,就是要增加一个下拉框,选中里面的数据后,显示在文本域中,不知道怎么写,写了多次都报EXT-all-dub.js的错误。
附件中有关于这个操作的图片。。。谢谢了。
原代码:

xtype:"window",
 title:"任务派遣",
 width:500,
 modal:true,
 height:400,
 layout:"fit",
 initComponent: function(){
  orgWindow = new HM.orgWindow({rootId:this.rootOrg, withUser:false,rootText:this.rootOrgText,singleSelect:true,onSave:function(o){
    this.form.getForm().findField("sendOrg").setValue(o.tree.getValue());
    this.form.getForm().findField("_sendOrg").setValue(o.tree.getValue("text"));
    o.hide();
   }.createDelegate(this)
  });
  orgWindow2 = new HM.orgWindow({rootId:this.rootOrg, withUser:false,rootText:this.rootOrgText,onSave:function(o){
    this.form.getForm().findField("assistOrg").setValue(o.tree.getValues());
    this.form.getForm().findField("_assistOrg").setValue(o.tree.getValues(null,"text"));
    o.hide();
   }.createDelegate(this)
  });
  this.form = new Ext.form.FormPanel({
      xtype:"form",
      title:"",
      labelWidth:80,
      labelAlign:"right",
      layout:"form",
      region:"center",
      items:[{
        xtype:"hidden",
        name:"sendOrg"
       },{
        xtype:"hidden",
        name:"assistOrg"
       },{
        layout:"column",
        anchor:"100%",
        items:[{
         layout:"form",
         columnWidth:.85,
         items:[{
          xtype:"textfield",
          fieldLabel:"主办部门",
          allowBlank:false,
          name:"_sendOrg",
          readOnly :true,
          anchor:"95%",
          listeners:{
           focus:orgWindow.show.createDelegate(orgWindow)
          }
         }]
         },{
          columnWidth:.12,
          items:[{
           xtype:"button",
           text:"选择",
           //icon:rootPath + '/images/commons/orgempty.png',
           handler:function(){orgWindow.show()}
         }]
        }]
       },{
        layout:"column",
        anchor:"100%",
        items:[{
         layout:"form",
         columnWidth:.85,
         items:[{
          xtype:"textfield",
          fieldLabel:"协办部门",
          name:"_assistOrg",
          readOnly :true,
          anchor:"95%",
          listeners:{
           focus:orgWindow2.show.createDelegate(orgWindow2)
          }
         }]
         },{
          columnWidth:.12,
          items:[{
           xtype:"button",
           text:"选择",
           //icon:rootPath + '/images/commons/orgempty.png',
           handler:function(){orgWindow2.show()}
         }]
        }]
       },
       {
       
        xtype:"textfield",
        fieldLabel:"派遣常用语",
        name:"habitwords",
        anchor:"95%",
        height:20
       
       },
       {
        xtype:"textarea",
        fieldLabel:"派遣意见",
        maxLength:500,
        name:"opinion",
        anchor:"95%",
        height:200
       },
       {
        xtype:"datefield",
        fieldLabel:"完成截止时间",
        allowBlank:false,
        format : 'Y-m-d H:i',
        menu:new DatetimeMenu(),
        name:"rollEndTime",
        anchor:"95%"
       }
      ]
     });
  this.items=[
   {
    xtype:"panel",
    title:"",
    autoScroll:true,
    frame:true,
    layout:"border",
    items:[
     this.form
    ]
   }
  ];
  this.buttons = [{
   text:"确定",
   handler:function(){
    if(this.form.getForm().isValid()){
     if(this.form.getForm().findField('rollEndTime').getValue().getTime()<new Date().getTime()){
      Ext.Msg.alert("提示", "完成截止时间不能早于当前时间!");
      return;
     }
     this.submit();
    }
   },
   scope:this
  },{
   text:"关闭",
   handler:function(){
    this.hide();
   },
   scope:this
  }]
  HM.workflow.sendWindow.superclass.initComponent.call(this);
 }

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • upup1000 2010-06-08 16:45
    已采纳

    那你就新加一个下拉框呗,加一个select监听,把value设置到相应的表单中就可以了

    combo必须指定一个Ext.data.Store对象或其子类的对象(或数组),必须指定displayField和valueField

    {
    xtype:"combo",
    store:store,
    displayField:"text",
    valueField:"text",
    name:"combo",
    fieldLabel:"",
    triggerAction:"all",
    listeners : {
    select : function(v){
    this.form.getForm().findField("xxx").setValue(v);
    },
    scope : this
    }
    }

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题