linjingqin
linjingqin
2009-08-24 18:51

combobox取值问题

  • ext
  • javascript

[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条回答