简体   繁体   English

真的没有办法挂入Ext.js组件的reset事件吗?

[英]Is there really no way to hook into the reset event of an Ext.js component?

When I reset a form in Ext.js it resets every child component, but the only events fired are invalid and valid . 当我在Ext.js中重置表单时,它将重置每个子组件,但是触发的唯一事件是invalidvalid It seems a bit "hacky" to hook them to handle the clearing of a value, is there no other way? 钩住它们以处理值的清除似乎有点“ hacky”,没有其他方法吗? The "problem domain" is that I am writing a plugin to create dependent comboboxes: “问题域”是我正在编写一个插件来创建依赖的组合框:

Ext.plugins.combobox.DependsOn = function(dependsOn) {
    function init() {
        var cb = this,
            parent = Ext.getCmp(dependsOn);

        parent.on("disable", function() {
            cb.clearValue();
            cb.disable();
        });

        parent.on("select", function() {
            cb.disable(); // dependents will be disabled
            cb.clearValue();

            cb.getStore().load();
            cb.enable();
        });

    }
    return {
        init: function(cb) {
            cb.afterRender = cb.afterRender.createSequence(init);
        }
    }
};

This works well until I call form.reset() at which point the comboboxes remain enabled but empty. 在我调用form.reset()之前,此方法一直有效,此时组合框保持启用状态,但为空。 I'd like to be able to hook some reset event and there disable and enable my top component to cascade a disabled state downwards. 我希望能够挂起一些reset事件,并在其中禁用并启用我的顶部组件以向下层叠禁用状态。 Alas, it seems impossible but I hope someone has a smart answer. las,这似乎是不可能的,但我希望有人能提供一个明智的答案。

Thank you. 谢谢。

Assuming "parent" is an Ext.form.Field, you could use createSequence on parent.reset. 假设“ parent”是一个Ext.form.Field,则可以在parent.reset上使用createSequence。

parent.reset = parent.reset.createSequence(function(){
    //here, do what you would have done with parent.on('reset', ...)
});

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

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