function add(){
store.load();
$('#userId').val("");
    win.show();
}function modify(){
var record = grid.getSelectionModel().getSelection();
if(record.length==0){
Ext.MessageBox.alert('提示', '请先选择数据!');
}else if(record.length>1){
Ext.MessageBox.alert('提示', '请选择一行数据!');
}else{
$('#userId').val(record[0].get("id"));
form.getForm().findField("username").setValue(record[0].get("username"));
form.getForm().findField("realname").setValue(record[0].get("realname"));
form.getForm().findField("password").setValue(record[0].get("password"));
form.getForm().findField("telephone").setValue(record[0].get("telephone"));
form.getForm().findField("email").setValue(record[0].get("email"));
form.getForm().findField("position").setValue(record[0].get("position"));
form.getForm().findField("department").setValue(record[0].get("department"));
form.getForm().findField("address").setValue(record[0].get("address"));
form.getForm().findField("flag").setValue(record[0].get("flag"));
form.getForm().findField("sex").setValue(record[0].get("sex"));
        win.show();
}
} function  readOnlyValue(){
if($('#userId').val("")!=""){
return true;//不可以修改
}else{
return false;//可以修改
}
}
{
                xtype: 'textfield',
                fieldLabel: '登录账号',
readOnly : readOnlyValue(),
                name:'username',
                blankText:'登录账号不能为空',
                allowBlank: false
            }在这里我想当点击add函数的时候将readOnly 值设为false。可以编辑的,当点击修改的时候将readOnly 值设为true.
现在的问题:我先点击那个函数就会一直是true或者false;
例如:我先点击add函数,出来的界面是可以编辑的,但是我在点击modify的时候还是可以便捷的。似乎窗口中的值没有改变,都是可以修改的。如果先点击modify结果和先点击add函数相反。