View Full Version : Showing an image in a view, the MVC way

21 Aug 2012, 3:12 AM
given the example here (http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture , section "Controlling the grid"), i see how fields from the current record are passed along to the view that edits the users.

given that example, how would i show an image that depends on a value of the record that gets passed to the view?

i can pass along a parameter in the controller while instantiating the view, like
var view =Ext.widget (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-widget)('useredit', {someparam: 'somevalue'}); and retrieve this parameter in the view via
this.someparam, but that doesn't seem very MVC compliant to me.

21 Aug 2012, 11:32 AM
The use of MVC is to organize your code and allow others to follow. This does not mean that you need to stop using basic methods in your code.

Your controller simply handles where the actions are called.


21 Aug 2012, 8:49 PM
erm ... ok. that's not what i ment.

i have a model like this

Ext.define('MM.model.Magnet', { extend: 'Ext.data.Model',
fields: [
{ name: 'id', mapping: '@id', type: 'int'},
'title', 'contributor_id', 'img_name', 'city', 'notes', 'country_id',
{ name: 'country', sortType: 'asCountry', convert: lookupCountry },
{ name: 'contributor', convert: lookupContributor }

img_name is the path of the image I'm trying to show in the view. so by passing that path as parameter while instantiating the view I would do something already done by the command

what I'm really asking for is an easy way to do an image form component. sticking to the example from my first post, something like

xtype: 'form', items: [
xtype: 'textfield',
name : 'name',
fieldLabel: 'Name'
xtype: 'textfield',
name : 'email',
fieldLabel: 'Email'
xtype: 'imagefield',
name : 'someimage',
fieldLabel: 'An Image'


21 Aug 2012, 8:55 PM
this is what I'm looking for (just a stripped down version I can actually understand)