linjingqin 2009-08-24 18:51
浏览 185
已采纳

combobox取值问题

[code="js"]
var profileListStore = new Ext.data.JsonStore({
url : 'userprofile.do?method=getUserProfileList',
root : 'profileList',
autoLoad : true,
fields : ['profileID', 'profileName', 'profileShare']
});
//----------------store-----------------------//
var profileList = new Ext.form.ComboBox({
id : 'ef_comprofileList',
editable : false,
store : profileListStore,
labelSeparator : '',
fieldLabel : 'Profile List',
hiddenName:'testhidden',
mode : 'local',
// hiddenName :'profileID',
triggerAction : 'all',
tpl : new Ext.XTemplate(
''
+ ''
+ '

[Pub]{profileName}
'
+ ''
+ ''
+ '
[Pri]{profileName}
'
+ '' + ''
+ '
{profileName}
'
+ '' + '', {
isPub : function(val) {
return val == 'Public';
},
isPri : function(val) {
return val == 'Private'
},
isempty : function(val) {
if (val == "") {
return true
} else {
return false
}
}
}),
displayField : 'profileName',
valueField : 'profileID',
selectOnFocus : true,
onSelect : function(record, index) {
if (this.fireEvent('beforeselect', this, record, index) !== false) {
if(record.data.profileShare=='Public'){
this
.setValue('[Pub]'+record.data[this.displayField
|| this.valueField]);
}else if(record.data.profileShare=='Private'){
this
.setValue('[Pri]'+record.data[this.displayField
|| this.valueField]);
}else{
this
.setValue(record.data[this.valueField
|| this.displayField]);
}
this.collapse();
this.fireEvent('select', this, record, index);
}
}
});
var profileRecord = Ext.data.Record.create([{
name : 'profileID',
mapping : 'profileID'
}, {
name : 'profileName',
mapping : 'profileName'
}, {
name : 'profileShare',
mapping : 'profileShare'
}]);
var myNewRecord = new profileRecord({
profileID : '0',
profileName : '--Add new profile--',
profileShare : ''

        });
profileListStore.on('load', function(store, records, options) {

    //              var a=records.length;
    //              for(var i=0;i<records.length;i++){
    //                if(records[i].json.profileShare=='Public'){
    //                  records[i].set('[Pub]'+records[i].data.profileName)
    //                }else if(records[i].json.profileShare=='Private'){
    //                  records[i].set('[Pri]'+records[i].data.profileName)
    //                }
    //              }

    this.insert(0, myNewRecord);
    profileList.setValue('0');
        //              console.log(myNewRecord,alarmCategoryStore.getCount())
    });

[/code]
store的数据:{"success":"true","profileList":[{"profileID":"1","profileShare":"Public","profileName":"Default"}]}
提交到后台时,就老是把'profileName'的值提交上去,而不是'profileID'的值,,用hiddenName:'testhidden',了,不知道是不是自己大意了,还是能把是'profileID'的值发到后台

请解答下
谢谢

  • 写回答

2条回答

  • iteye_10013 2009-08-25 09:05
    关注

    id/name传的是displayField
    hiddenName传的是valueField -- 实际上就是生成一个hidden类型的input

    你用firebug看下对应的这个input的值是什么

    另外,可以先把tpl等干扰因素去掉先

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大