1

我们有一个屏幕上的业务规则,在特定条件下我可以执行一些操作。现在升级到 ExtJS 6.5 后,有些东西坏了。

下面的代码总结了我的问题

每当有人单击它时,我基本上想将复选框设置为 false。

仅供参考,我不能在我的问题中使用 setReadonly() 。

版本 5.1.3.228 上的行为:未选中复选框,这是版本 6.5.2.463 上的预期行为:选中复选框,之后,您无法取消选中它。

Ext.application({
    name : 'Fiddle',
    launch : function() {
           Ext.create('Ext.form.Panel', {
            bodyPadding: 10,
            width: 300,
            title: 'Checkbox Title',
            items: [
                {
                    xtype: 'fieldcontainer',
                    fieldLabel: 'This is Checkbox',
                    defaultType: 'checkbox',
                    items: [
                        {
                            boxLabel  : 'Check me',
                            name      : 'checkbox',
                            listeners : {
                                change : function (){
                                    this.setValue(false)
                                }
                            }
                        }
                    ]
                }
            ],
            renderTo: Ext.getBody()
        });
    }
});

4

1 回答 1

1

您可以使用 this.setChecked 来保留您的功能。

Ext.application({
    name : 'Fiddle',
    launch : function() {
       Ext.Msg.show({
            bodyPadding: 10,
            width: 300,
            title: 'Checkbox Title',
            items: [
                {
                    xtype: 'fieldcontainer',
                    fieldLabel: 'This is Checkbox',
                    defaultType: 'checkbox',
                    items: [
                        {
                            boxLabel  : 'Check me',
                            name      : 'checkbox',
                            checked: true,
                            listeners : {
                                change : function () {
                                    this.setChecked(false);
                                }
                            }
                        }
                    ]
                }
            ],
        });
    }
});

(使用 Ext.Msg.show 在小提琴中查看面板)

于 2019-09-09T14:45:23.897 回答