首页 > 解决方案 > 当用户从确认框中选择否时,如何设置单选按钮的旧值?

问题描述

我有一个问题,当用户在单选按钮上进行更改时,我必须触发用户确认框。

我成功触发了确认框,但对我来说很难在无线电组中设置旧值。任何人都有这样做的想法。我尝试在谷歌上提到解决方案,但没有运气。

Ext.define('CustomRadioField', {
override: 'RadioField',
setListeners: function(config) {
    var me = this;
    config.listeners = {
            change: {
                fn: function(control, newValue, oldValue, eOpts) {
                    var me = this;
                    me.fieldChanged();
                    Ext.Msg.confirm(MyFunction.T('Confirm'), "Are you sure want to delete?", function(btn) {
                        if (btn == 'no') {
                            //Added my logic to reset back
                            control.suspendEvent('change');
                            control.setValue(oldValue);
                            control.resumeEvent('change');
                            //End
                           //Added to refresh page not to reload but this location.reload post to my server insted to refresh.
                            location.reload();
                        }
                        if (btn == 'yes') {


                        }
                    });

                }
            },
            scope: me
        },
        focus: {
            fn: me.storeFocusField,
            scope: me
        },
        afterrender: {
            fn: function(f, e) {
                me.setFieldFocus;

            },
            scope: me
        },
        boxready: {
            fn: me.setUpChangeEvent,
            scope: me
        },
        specialkey: {
            fn: function(f, e) {
                var me = this;
                switch (e.getKey()) {
                    case e.TAB:

                        break;
                }
            },
            scope: me
        }
};
},

});

提前致谢

标签: javascriptextjs

解决方案


你能附上代码吗?

您可以使用field.reset()函数重置字段值,其中字段是单选按钮字段,或者您可以使用form.reset()方法将表单中的所有字段重置为用户更改之前的状态。


推荐阅读