1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    11
    Vote Rating
    0
    lightxx is on a distinguished road

      0  

    Default Unanswered: Showing an image in a view, the MVC way

    Unanswered: Showing an image in a view, the MVC way


    given the example here (http://docs.sencha.com/ext-js/4-0/#!...n_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
    Code:
    var view =Ext.widget('useredit', {someparam: 'somevalue'});
    and retrieve this parameter in the view via
    Code:
    this.someparam
    , but that doesn't seem very MVC compliant to me.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,984
    Answers
    662
    Vote Rating
    455
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    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.

    Scott.

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    11
    Vote Rating
    0
    lightxx is on a distinguished road

      0  

    Default


    erm ... ok. that's not what i ment.

    i have a model like this

    Code:
    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
    Code:
     view.down('form').loadRecord(record);
    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

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

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Posts
    11
    Vote Rating
    0
    lightxx is on a distinguished road

      0  

    Default


    this is what I'm looking for (just a stripped down version I can actually understand)

    http://stackoverflow.com/questions/1...32203#10932203

Thread Participants: 1

Tags for this Thread