简体   繁体   English

有没有办法在 ext js 中重新渲染复选框?

[英]is there any way to re-render checkbox in ext js?

i have following code我有以下代码

    extend: 'Ext.container.Viewport',
    initComponent: function () {
        var me = this;
        me.items = [
            {
                xtype: 'checkbox',
                fieldLabel: 'RPTest',
                itemId:'chk1'
            },
            {
                xtype: 'button',
                text: 'test',
                handler: function () {
                    me.chk1.setBoxLabel(me.chk1.fieldLabel);
                    me.chk1.boxLabelAlign = 'before';

                    me.chk1.setFieldLabel('');
                }
            }
        ];
        me.callParent(arguments);
        me.chk1 = me.down('#chk1');
    }
})

i want to update boxLabelAlign property whenever user click button property values changes but DOM doesn't update i have tried updateLayout() of checkbox but it doesn't works.每当用户单击按钮属性值发生更改但 DOM 未更新时,我想更新boxLabelAlign属性我尝试了复选框的 updateLayout() 但它不起作用。 so is there any solution of these problem?那么这些问题有什么解决方案吗? or is there any way to update DOM??或者有什么方法可以更新 DOM?

You should use the setConfig() method to assign the new boxLabelAlign property instead of assigning the value directly.您应该使用setConfig()方法来分配新的boxLabelAlign属性,而不是直接分配值。 Here is how:方法如下:

var checkbox = Ext.create({
    xtype: 'checkbox',
    boxLabelAlign: 'after',
    boxLabel: 'ltest'
})

var button = Ext.create({
    xtype: 'button',
    text: 'CLICK ME',
    handler: function () {
        checkbox.setConfig({
            boxLabelAlign: 'before'
        })
    }
})

Ext.create('Ext.panel.Panel', {
    title: 'Setting label align',
    items: [
        checkbox,
        button
    ],
    renderTo: Ext.getBody()
});

You can change the initialConfigs of an Ext js element using the element.setConfig({...}) method您可以使用element.setConfig({...})方法更改 Ext js 元素的initialConfigs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM