PDA

View Full Version : Dynamic update image in the form



porcelanosa
27 Feb 2009, 3:08 PM
Sorry for my English, i`am russian

I Have grid. On the click on the row -open form. Form consist the image - path to image store on the DB - i get it and other data from grid selection.



var fileUploadPhotoPreview ={// component with image
xtype:'box',
autoEl:{tag:'img',src:'',id:'photo_preview', name:'photo_preview'}
}
...........................
var selections = EditorGrid.selModel.getSelections();
FirstNameField_ed.setValue(selections[0].json.firstname); // text field
fileUploadPhotoPreview.autoEl.src=selections[0].json.image; // update img src
It work fine on first click, but when I close the form and select another row - in the form shown first image (from first clicked grid row)
FireBug show me that fileUploadPhotoPreview.autoEl.src value update correct, but image in the form stay previous
Help me please!

mankz
27 Feb 2009, 3:12 PM
autoEl is only used the first time your component is constructed. Try this instead:


Ext.getDom('photo_preview').src = selections[0].json.image;

Not sure it'll work but worth a try :)

nicolasbkz
27 May 2010, 8:22 AM
If works fine, thank you.