我正在使用 ExtJS 3.3,我的
formpanel
有以下代码:
Ext.apply(this, {
items: [{
xtype: 'textfield',
fieldLabel: 'ApplicationGUID',
labelAlign: 'right',
name: 'Application_GUID',
value: 0,
readOnly: false,
width: 300
},
{
xtype: 'textfield',
fieldLabel: 'ApplicationName',
labelAlign: 'right',
name: 'Application_Name',
anchor: '-20',
msgTarget: 'side'
}
], //eof items
tbar: [{
xtype: 'mydeletebutton',
scope: this,
ownerCt: this,
handler: this.deleteHandler,
myAuth: {
compBaseRights: {
Delete: {
failProperty: {
disabled: false
}
} /*eof Delete*/
} /*eof compBaseRights*/
} /*eof sgAuth*/
}, {
xtype: 'tbseparator'
}, {
xtype: 'trashcanbutton',
scope: this,
ownerCt: this,
handler: this.setIsDeletedHandler,
myAuth: {
compBaseRights: {
Insert: {
failProperty: {
disabled: false
}
} /*eof Delete*/
} /*eof compBaseRights*/
}
}, {
xtype: 'mytrashcanrestorebutton',
scope: this,
ownerCt: this,
handler: this.unsetIsDeletedHandler,
myAuth: {
compBaseRights: {
Insert: {
failProperty: {
disabled: false
}
} /*eof Delete*/
} /*eof compBaseRights*/
}
}, {
xtype: 'tbseparator'
}, {
xtype: 'mysavebutton',
scope: this,
handler: this.saveHandler,
myAuth: {
compBaseRights: {
Write: {
failProperty: {
disabled: false
}
} /*eof Delete*/
} /*eof compBaseRights*/
}
}],
bbar: {
xtype: 'mystatusbar'
}
});
我正在寻找的是,对于
textfield
Application_GUID,如果值已经存在(例如当我双击网格中的现有值以对其进行编辑时),我需要是readOnly: true
,并且如果我按我的 grid
上的新按钮,我需要 readonly
声明为 false
。
如果有人可以帮助我,那就太好了。谢谢。
一个好的技术是设置一个布尔变量来初始化为 false。然后根据自己的需要设置为true。
然后添加所需的侦听器,如以下示例代码所示,例如在更改侦听器上:
listeners: {
yourlistener: function(e) { //yourlistener can be change, select, etc...
if (booleanVariable === true) Ext.getCmp('your-textbox-id').setReadOnly(true);
else Ext.getCmp('your-textbox-id').setReadOnly(false);
}
}
或者使用 boxready 函数,然后使用更改函数来获取 单击或未单击时发生事件,然后设置变量