PDA

View Full Version : How to put an Image at form using php header image types



opessoa
26 May 2014, 11:44 AM
Hi everyone!

I have a Mysql table with one blob image column, who I getter from this sample url: http://192.168.0.30/mtdesktop/app/php/usuario/imagemUsuario.php?usuario_id=1 (thats (http://192.168.0.30/mtdesktop/app/php/usuario/imagemUsuario.php?usuario_id=1</a> (thats) ok)

I have a user store/view/controller. {id,name,age}

So, I have a form like this:



initComponent: function() {

this.items = [
{
xtype: 'form',
padding: '5 5 5 5',
border: false,
style: 'background-color: #fff;',

fieldDefaults: {
anchor: '100%',
labelAlign: 'left',
allowBlank: false,
combineErrors: true,
msgTarget: 'side'
},

items: [
{
xtype: 'textfield',
name : 'id',
id:'userID',
fieldLabel: 'id',
hidden:true
},
{
xtype: 'textfield',
name : 'name',
fieldLabel: 'Name'
},
{
xtype: 'image',
name : 'id',
//Thats what I needed
render: function(component){
var myComp = Ext.getCmp('userID').getValue() ;
component.el.dom.innerHTML = '<img id="{id}" class="{fieldCls}" src="app/php/usuario/imagemUsuario.php?usuario_id=' + myComp + '"/>';
}
}
...


But, myComp is always empty. How to get any value from my record? I have used MVC.

mitchellsimoens
29 May 2014, 4:15 AM
Couple issues I see. You are overriding the render method of Ext.Img which is bad. You should use the setSrc method on the Ext.Img instance to set the src. The value of the field may not be set when the Ext.Img is being rendered.

opessoa
29 May 2014, 6:24 AM
Ok, and, how to set a name to get url with the record value with the setSrc?

mitchellsimoens
29 May 2014, 6:24 AM
are you using the loadRecord method on the form to set the values from the record onto the form?

opessoa
29 May 2014, 8:24 AM
I'm using MVC, controller, model, store and view... Like ext samples.


But, yes, on editItem function, after dblckick item on my grid:

ExtMVC.view.lancamento.Formulario is a window.



editItem : function(grid, record) {
var edit = Ext.create('ExtMVC.view.lancamento.Formulario').show();

if(record){
edit.down('form').loadRecord(record);
}
},


So, if I do it on my form items:


{
xtype: 'image',
name : 'id',
src: 'app/php/usuario/imagemUsuario.php?usuario_id=' + {value};
}


That will work?