开发者

ExtJS: show/hide events don't cascade down?

Is there a known limitation (or bug?) in ExtJS 3.2.x where events like show/hide fail to always be cascaded down a hierarchy of panels?

I have a panel that is nested inside a hierarchy of other panels. This panel's "show" event only fires the very first time it's shown. The "show" event in the "root" panel fires every time, however.

This forum post seems to indicate that events are not cascaded in 3.x. Can someone confirm or offer more info?

开发者_开发问答

Thanks!


Show/hide events are indeed not cascaded. The reason is that show/hide is actually just a dom manipulation and has nothing to do with the component hierarchy.

If a component contains sub components they are dom descendants of the containing component and thus also hidden if the containing components dom node is hidden. But this is just a side effect of the dom hierarchy of the components, not of the component hierarchy.


You may be able to cascade using the cascade method, if the component you are working with supports it (Ext.layout.Panels do). For example, if you had a panel, contained within a panel, and you wanted to hiden the child panel when the parent was hidden, you could try this:

validXTypes = ['panel'] //include any other valid types

parentPanel.cascade(function () {
    //if this component can be hidden...
    if (validXTypes.indexOf(this.xtype) != -1) {
        //...then hide it!
        this.hide();
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜