【发布时间】:2012-02-08 14:58:56
【问题描述】:
我想在 EXTJS 中启用或禁用复选框
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'radiofield',
id: 'all',
name: 'show',
boxLabel: 'All',
checked: true,
inputValue: 'all'
}, {
xtype: 'radiofield',
id: 'online',
name: 'show',
boxLabel: 'Online',
inputValue: 'online'
}, {
xtype: 'radiofield',
id: 'offline',
name: 'show',
boxLabel: 'Offline',
inputValue: 'offline'
}, {
xtype: 'checkboxfield',
id: 'cb1',
boxLabel: 'Sometimes',
checked: true,
inputValue: 'sometimes'
}, {
xtype: 'checkboxfield',
id: 'cb2',
boxLabel: 'Always',
checked: true,
inputValue: 'always'
}],
listeners: {
change: function (field, newValue, oldValue) {
var value = newValue.show;
if (value == 'all') {
var cb1 = Ext.getCmp('cb1');
var cb2 = Ext.getCmp('cb2');
cb1.disable();
cb2.disable();
}
if (value == 'online') {
var cb1 = Ext.getCmp('cb1');
var cb2 = Ext.getCmp('cb2');
cb1.disable();
cb2.disable();
}
if (value == 'offline') {
var cb1 = Ext.getCmp('cb1');
var cb2 = Ext.getCmp('cb2');
cb1.enable();
cb2.enable();
}
}
}
}]
如何启用这些复选框?当用户选择离线选项时应该启用它们,当用户选择其他选项时应该禁用它们。
感谢您的帮助!
【问题讨论】:
标签: extjs checkbox radio-button