0

So I want to add a component to the bottom of a panel. Normally you would just do the following:

Ext.getCmp('xxxx').add({....});

and that will add to the bottom, but for some reason when you add itemId it all goes to hell. Here is a working example: http://jsfiddle.net/Qsfgh/ Notice how the 'higher' id comes before the lower one. (You can open your console and look at the HTML if you want to verify) Even when I use an 'insert' and I insert it at the very end it still puts it at the beginning. How do I get around that?

Aram Papazian
  • 2,453
  • 6
  • 38
  • 45
  • In your fiddle, I see "Last Name 1" first, and "Last Name 2" second. That is to say, in the order you added them. As expected. The DOM ids are indeed in reverse order, but... Why would you care? – rixo Jun 28 '13 at 02:52
  • Because when you hit the 'tab' key you go from last name 2 to last name 1 (Yes I can change the tab index, but I have 20 inputs being created at a time... seems like there should be a better way) – Aram Papazian Jun 28 '13 at 16:49
  • Also, the 'order' I added them wouldn't matter for display as they are both positioned absolutely. But they would matter for HTML which is the crux of the issue =) – Aram Papazian Jun 28 '13 at 22:39

1 Answers1

1

Both the fields you're adding have the same itemId. ItemIds don't have to be globally unique, but they do have to be unique for components within the same container. The itemId is used as the key for a component in the owning container's mixed collection of items (if no itemId is set on the component, the id is used instead).

So when you are adding the second field, it replaces the first field in the container's collection of items and screws up the rendering process. Give the fields different itemIds and everything will work properly.

If you give each field a unique itemId you no longer need to absolutely position the fields. Field 2 will be placed correctly beneath Field 1

wantok
  • 977
  • 5
  • 16