简体   繁体   English

从extjs面板中删除其他组件后,为什么不显示新添加的组件

[英]why do newly added components not display after removing other components from extjs panel

In ExtJs 6 classic, I have an Ext.panel.Panel that I have added children to, some of these children are dynamically created Panels and containers. 在ExtJs 6 classic中,我有一个Ext.panel.Panel,我已经添加了子级,其中一些子级是动态创建的Panels和容器。 I save references to these containers and remove them from the parent Panel (this) like so: 我保存对这些容器的引用,并将其从父面板中删除(如下):

    if (this.myChildPanels.length > 0) {
        for (var i = this.myChildPanels.length - 1; i >= 0; i--) {
            this.remove(this.myChildPanels[i], true);
        }
        this.remove(this.queryById('finalPanel'), true);
        this.myChildPanels= [];
    }

These child panels do disappear and no longer display as expected. 这些子面板确实消失了,不再按预期显示。

However when I attempt to add new containers back to the parent panel (this), the new panels do not display 但是,当我尝试将新容器添加回父面板(此)时,新面板不显示

    this.add(Ext.create('Ext.container.Container', { 
          width: '200px',
          height: '400px',
          layout: {
             type: 'fit'
          },
          items: [ {
             xtype: 'label',
             text: 'Some stuff'
          }]
    ));

The parent is using a fit layout, are there any methods I need to call on the parent Panel after removing and before adding new components to it? 父级使用的是合适的布局,在移除父级面板后再向其添加新组件之前,我是否需要调用任何方法? The dynamic addition works the first time, but not after removing components that were dynamically added (kicked off by button press). 动态添加是第一次使用,但是在删除动态添加的组件(通过按下按钮将其删除)之后才起作用。

use this.removeAll() function to remove all child elements in your panel. 使用this.removeAll()函数删除面板中的所有子元素。 after adding some new elements try to call updateLayout function. 添加一些新元素后,尝试调用updateLayout函数。 if this solution does not help provide fiddle example recreating your problem to work with. 如果此解决方案无法帮助您提供提提琴的示例,请重新创建您要解决的问题。

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

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