玩Extreact,我的页面上有一个复选框,我想要控制它的选中状态。例如,我希望在我的状态中设置选中的值,并且能够在不以用户身份单击输入的情况下检查或取消该输入。
问题是,CheckboxField只有一个引用初始状态的checked支柱,因此它在之后非常无用。
发布于 2018-03-20 21:15:46
这是不可能的框,以防止点击改变状态,但这是相当容易实现的覆盖。小提琴。
Ext.define(null, {
override: 'Ext.field.Checkbox',
updateReadOnly: function (value, oldValue) {
this.callParent([value, oldValue]);
this.inputElement.dom.onclick = value ? function () {
return false;
} : null;
}
})
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.Viewport.add({
xtype: 'container',
items: [{
id: 'foo',
xtype: 'checkbox',
readOnly: true
}, {
xtype: 'button',
text: 'On',
handler: function () {
Ext.getCmp('foo').check();
}
}, {
xtype: 'button',
text: 'Off',
handler: function () {
Ext.getCmp('foo').uncheck();
}
}]
});
}
});https://stackoverflow.com/questions/49391056
复制相似问题