日期:2014-05-16  浏览次数:20666 次

Ext中的Combobox怎么取值
现在我只能取到text,区不到他的value(不提交到服务器,只是在前台取值)

JScript code

var combo = new Ext.form.ComboBox({
   width:127,
   height:50,
   renderTo:'div_com',
   mode:'remote',
   triggerAction:'all',
   id:'filiale',
   name:'filiale',
   value:'请选择..',
   allowBlank: false,
   handleHeight:5,
   listWidth :150,
   maxHeight:100,
   readOnly:true,
   valueFiled:'fid',
   displayField:'title',
   store:new Ext.data.JsonStore({
       url: '../../MyPages/Colligate/UploadFiliale.aspx?id='+encodeURI(v),
       root: 'data',
       fields: ['title','fid']
   }),
   listeners:{
       'select':function(arg){
           var d = arg.value;
           alert(Ext.get("filiale").dom.value);
           alert(Ext.getCmp("filiale").getValue());
       }
   }
});




------解决方案--------------------
var comtext = combo.getRawValue();
就能获得text的内容。
------解决方案--------------------

 在 fields: ['title','fid'] 中 把 fid 和 title 的位置换一下 如:fields: ['fid','title'] ,而且你的 select 事件的参数错了,如果实在不行的话,参照我下列贴上的源码进行对比。
  
JScript code

var combo = new Ext.form.ComboBox({
     id:'filiale',
     fieldLabel:"所在组",
     hiddenName:"groupId",  // 下拉框在 HTML 中显示的名称
      allowBlank :false,
     width:201,
     selectOnFocus:true,
     valueField:"fid",      // 提交表单时,下拉框的值
      displayField:'title',   // 显示在页面上下拉框的值
      emptyText:'请选择..',
     editable:false,
     mode:"local",
     forceSelection:true,
     triggerAction:'all',
     allowBlank:false,
     store: new Ext.data.JsonStore({
          // 动态从后台提取数据并填充到 ComboBox
          autoLoad:true,
          fields: ['fid', 'title'],
          url: '../../MyPages/Colligate/UploadFiliale.aspx?id='+encodeURI(v),
     }),
     typeAhead: true,
     listeners:{
         select  :function(combo,record,index){
              alert(combo.value);
         }
     }        
});