user191542
user191542

Reputation: 285

How can i get the ExtJs item from the panel if i have its name

I have the Form Panel and then i have 10 form fields in it like textbox etc.

Now i have those stored in javascript array of objects like this Fieldarray = []

Now is there any way from that array i can get the each field by its name.

I want to insert those fields in different form

Something like

NameFieldObject = getElement(fieldArray, 'firstname')

so that i get the firstname object from that array for ExtJS elements

Upvotes: 0

Views: 1521

Answers (2)

Prasad K - Google
Prasad K - Google

Reputation: 2584

While supporting existdissolve's answer, what else I can suggest you is to make Fieldarray an object with keys as fieldnames/ids instead of an array so that lookup will be easier.

Example: Fieldarray = { firstName: field1, lastName: field2}

Upvotes: 1

existdissolve
existdissolve

Reputation: 3114

I think you can dispense with the custom array...a form panel already has access to its own children, and has a number of built-in methods that can be used to deal with all fields, individual fields, etc.

For example, to find a particular field by name, you can simply use the findField() method, as documented here: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Basic-method-findField

Upvotes: 0

Related Questions