PDA

View Full Version : Get all the passwordfield on the current active view



janaja
24 Jul 2012, 4:59 AM
Hello everyone,
I have been trying to get all the passwordfield components that are being displayed on the current active view.

I am trying something along the lines of the following:


var activeView = Ext.Viewport.getActiveItem();
var objects = activeView.query('passwordfield');
for (var index =0; index < objects.length;index++){
//Do stuff
console.log('>>> objects[i] Class name=.... : ' + Ext.getClassName(objects[i]));
}

The class printed is always empty and whenever I try to call any of the passwordfield's APIs I get an exception.

jerome76
24 Jul 2012, 6:40 AM
Trying to query the items of a view like that never worked for me, but this could work:


//query all direct children
Ext.ComponentQuery.query('#activeViewItemIdHere > passwordfield');

estesbubba
24 Jul 2012, 6:47 AM
I bet objects[index] will work better :)

jerome76
24 Jul 2012, 6:52 AM
I bet objects[index] will work better :)
Haha I totally did not catch that ;)

estesbubba
24 Jul 2012, 7:16 AM
I always use Ext.each() instead of for() for arrays.

janaja
26 Jul 2012, 2:11 AM
Thanks guys :)
Well spotted !
Such a stupid mistake