I have this fieldset with image component inside:
{
xtype : 'fieldset',
title : 'Picture',
width : 170,
items : [{
xtype : 'image',
itemId : 'uploadImage',
height : 150,
width : 150,
src : ''
}]
}
The field set is inside a window called with alias: widget.profile, so I am using this line to access my image component
Ext.ComponentQuery.query('profile [itemId=uploadImage]');
Ok it gives me the image component and there is function setSrc() but I cannot use it, as if there is some permission on it. What do I do wrong, or is there a bug in extjs 4.2?
Your code
Ext.ComponentQuery.query('profile [itemId=uploadImage]');
returns array of matched components not single component. So if you have in your application only one component which match the query you can get it by:
var img = Ext.ComponentQuery.query('profile [itemId=uploadImage]')[0];
Then you can set src of the image:
img.setSrc('http://www.sencha.com/img/v2/logo.png');