问题描述
我需要根据Session中的用户个人信息 给用户的生日和性别填充值 但是不知道怎么写 这是我的代码//个人信息reader var reader=new Ext.data.JsonReader({root : 'user'}, [{name:'u.id',mapping:'id',type:'integer'}, {name : 'u.name',mapping:'name',type:'string'}, {name : 'u.serialNum',mapping:'serialNum',type:'string'}, {name : 'u.sex',mapping:'sex',type:'string'}, {name : 'u.phone',mapping:'phone',type:'string'},{name:'u.email',mapping:'email',type:'string'},{name:'u.address',mapping:'address',type:'string'},{name:'u.idcard',mapping:'idcard',type:'string'},{name:'u.description',mapping:'description',type:'string'},{name:'u.takeOfficeDate',mapping:'takeOfficeDate',type:'date'},{name:'u.telephone',mapping:'telephone',type:'string'},{name:'u.birthday',mapping:'birthday',type:'date'}])//个人资料Formvar myInfoForm = new Ext.FormPanel({labelAlign : 'right',//width:700,id:'myInfoFormId',fileUpload:true,labelWidth : 87,reader:reader,layout:'column',frame : true,items : [{columnWidth:.8,items:[{title : "基本信息",xtype : "fieldset",layout : "column",autoHeight : true,autoWidth : true,items : [{layout : "form",columnWidth : .5,items : [{xtype : "textfield",fieldLabel : 'id',hideLabel : true,hidden : true,id:'empId',name : 'u.id'}, {xtype : "textfield",fieldLabel : "姓名",width : 140,allowBlank : false,name : "u.name"},{xtype:"datefield",fieldLabel:'出生日期',id:"takeOfficeDate",format: 'Y-m-d',width:140,name:'u.birthday'}]},{layout:"form",columnWidth:.5,items:[{xtype:"combo", fieldLabel: '性别', width:140, name: 'u.sex', store: new Ext.data.SimpleStore({ fields: ['value', 'text'], data: [ ['1', '男'], ['2', '女'] ] }), displayField: 'text', valueField: 'value', mode: 'local', emptyText:'男'}]}]}, {title : "用户其他资料",xtype : "fieldset",layout : "column",autoHeight : true,autoWidth : true,items : [{layout : "form",columnWidth : .5,items : [{xtype : "textfield",fieldLabel : "手机",width : 140,allowBlank : false,name : "u.phone"}]}, {layout : "form",columnWidth : .5,items : [{xtype : "textfield",fieldLabel : "工作电话",width : 140,name : "u.telephone"}]}, {layout : "form",columnWidth : 1.,items : [{xtype : "textfield",fieldLabel : "电子邮箱",width : 425,name : "u.email"}, {xtype : "textfield",fieldLabel : "家庭住址",allowBlank : false,width : 425,name : "u.address"}, {xtype : "textfield",fieldLabel : "身份证",allowBlank : false,width : 425,name : "u.idcard"}]}]}]},{layout:'column',columnWidth:.2,items:[{layout : "form",columnWidth : 1.,items:[{ xtype:'panel', border:false, xtype : 'box', id : 'browseImage', bodyStyle:'padding:10px 10px 10px 10px;', autoEl : { width : 120, height : 150, style:'margin : 16 0 0 10', tag : 'img' //src : avatarurl } },{ xtype : 'button', fieldLabel:'', style:'margin : 20 0 0 40', text:'上传头像', handler: function(){//方法二,直接调用var dialog = new Ext.ux.UploadDialog.Dialog({ width: 450, height: 300, title: '上传头像', url:'', base_params:'', reset_on_hide: false, allow_close_on_upload: true});dialog.show();// var file_path = Ext.getCmp('upload').getValue();// var str = file_path.substr(file_path.lastIndexOf('.')+1,file_path.length);// if(str!='JPG'&&str!='jpg'){// Ext.Msg.alert('错误', "上传的图像只能是jpg格式!"); // return false;// } }}]}]}]}); //修改个人信息窗口var updataInfoWin=new Ext.Window({title : '修改我的资料',id : 'updataInfoWin',constrain : true,// 整个窗口不允许超出浏览器modal : true,// 模拟页面失效resizable : false,width : 770,autoHeight : true,items : myInfoForm,buttons : [{text : '保存',handler : function() {if (!myInfoForm.form.isValid()) {return;}myInfoForm.form.submit({url : 'employee/employee!updateUser.action',method : 'post',waitTitle : "请稍候",waitMsg : '正在更新数据...',success : function(form, action) {if (action.result.success) {Ext.ensible.sample.msg('操作提示', '员工信息更新成功');}},failure : function(form, action) {Ext.Msg.alert('操作提示', '保存失败,原因可能是:n'+action.result);}});}},{text : '取消',handler : function() {updataInfoWin.hide();//alert(Ext.getCmp('functionPanelID'));//Ext.getCmp('functionPanelID').getActiveTab().hide();}}]});//最父级容器Panelvar myInformationPanel=new Ext.Panel({title : node.text,id : node.text,closable : true,border:false,listeners:{'activate':function(){updataInfoWin.show();myInfoForm.form.load({url:'employee/employee!loadMyInfo.action'});}}}); 性别写上后 可以正确显示 但是再点下拉 就只剩填充上的性别了 比如 用户是女的 cobbobox显示是女 但是点下拉 发现里面只有女的选项了
解决方案
combobox中加入属性 triggerAction: 'all',