Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add an ExtJs component at a specific position (index)?

I have a ToolBar with some components (TextFields and Buttons) and I would like to dynamically add a component (TextField, for example) before the other components.

I tried tbBar.add(myComponent); without success.

Any idea?

like image 463
Roberto Schuster Avatar asked Jul 08 '11 19:07

Roberto Schuster


2 Answers

You can use Ext.container.AbstractContainer.insert:

tbBar.insert(0, myComponent);
like image 118
Stefan Gehrig Avatar answered Sep 22 '22 00:09

Stefan Gehrig


As an additional information, you can use "Ext.container.AbstractContainer.container.items.indexOf" to get an index of a specific item in your container.

var index = container.items.indexOf(component);
container.insert(index, newComponent);
like image 27
Kohei Mikami Avatar answered Sep 21 '22 00:09

Kohei Mikami