PDA

View Full Version : [SOLVED]how to fetch all components which extends Ext.form.Field in a FormPanel?



madkris
16 Jul 2010, 6:01 PM
This one doesnt work.

var components = this.findByType(Ext.form.Field, true);
for (var j = 0; j < components.length; j++)
{
components[j].disable();
}

Animal
16 Jul 2010, 10:05 PM
findByType('field')

madkris
17 Jul 2010, 1:20 AM
Forgot to mention that I tried that too. Doesn't seem to work or maybe I misunderstood the docs?

tomtom-
17 Jul 2010, 2:42 AM
shallow : Boolean
(optional) False to check whether this Component is descended from the xtype (this is the default), or true to check whether this Component is directly of the specified xtype.
You set the second parameter to true. So, according to the documentation you are looking for components that are field xtyped (not descended xtypes). Now the title of the thread specify that you are extending Ext.form.Field if I'm right.



var components = this.findByType('field');
for (var j = 0; j < components.length; j++)
{
components[j].disable();
}

Animal
17 Jul 2010, 3:10 AM
findByType works. It just does.

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/as_usual_it_works.jpg

You are sure what "this" is when that runs? Because you have debugged BY STEPPING THROUGH CODE haven't you?

madkris
18 Jul 2010, 10:10 PM
@tomtom - Thanks, for the explanation! Actually I wasn't Extending Ext.form.Field, Ext JS already did that for me. :)

@Animal - Yes, of course. Sorry I missed that you omitted the second parameter.

Might not be worth posting but it might help someone.

From:

var types = ['textfield', 'radio', 'radiogroup'];
for (var i = 0; i < types.length; i++)
{
var components = this.findByType(types[i], true);
for (var j = 0; j < components.length; j++)
{
components[j].enable();
}
}

To:

var components = this.findByType('field');
for (var j = 0; j < components.length; j++)
{
components[j].enable();
}