问题描述
我有一个窗口,窗口里面有面板.我动态地向面板添加组件.这些组件采用hbox"布局,以便它们水平排列.单击按钮后,我将在hbox"布局中再向面板添加一行类似的组件.这里的问题是我想在第一行下面添加第二行,但是下面的代码将组件添加到面板的顶部.
I have a window with panel in inside the window. I add components to the panel dynamically. These components are in 'hbox' layout so that they are arranged horizontally. On click of a button i will add one more row of similar components in 'hbox' layout to the panel. Here the problem is that i want to add the second row below the first row, but the following code adds the components to the top of the panel.
panel.add(items); #items is the group of comboboxes in hbox layout
panel.doLayout();
有什么想法可以解决这个问题吗?这样我就可以在第一行下方添加第二行组件.
Any ideas to solve this problem? so that i can add second row of components below the first row.
Extjs 版本是 3.4
Extjs Version is 3.4
推荐答案
我找到了问题的原因.
原因:当我们将具有相同id"的组件添加到面板时,新添加的组件将被添加到面板的顶部.
Cause: when we add components with same 'id' to a panel, then the newly added component will get added to the top of the panel.
修复:在向面板添加相同组件时使用itemId"而不是id".
Fix: Use 'itemId' instead of 'id' while adding same component to the panel.
希望这对某人有用.
这篇关于ExtJs 面板 - 添加动态组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!