ExtJs panel - adding dynamic components

最后都变了- 提交于 2019-12-04 18:43:47

问题


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 Version is 3.4


回答1:


I found the cause of the problem.

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.

Fix: Use 'itemId' instead of 'id' while adding same component to the panel.

Hope this will be useful for someone.




回答2:


You can use insert method instead to specify the index of panel items that you want to put your component at:

var index = panel.items.length;
panel.insert(index, items);

// or if it always going to be the second item
panel.insert(1, items);

Here it is in the docs.



来源:https://stackoverflow.com/questions/12089123/extjs-panel-adding-dynamic-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!