1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    1
    Vote Rating
    0
    TrevorD is on a distinguished road

      0  

    Default Unanswered: Ext Js 4 MVC - Add Listener to Image in a grid panel

    Unanswered: Ext Js 4 MVC - Add Listener to Image in a grid panel


    I was wondering how to add a listener to an image that is displaying in a grid panel. I am not sure how to implement the click event on an image from the renderer function of a column. I would like to add an onclick event to the images. Should that be done in this view or the controller? I am a newbie and a little lost. Thanks.

    Code:
        Ext.define('MyApp.view.people.List' ,{
        extend: 'Ext.grid.Panel',
        alias: 'widget.myList',
        requires: [
            'MyApp.util.Globals',
            'MyApp.util.ImageTmpl'
        ],
    
    
        id: 'myGrid',
    
    
        title: 'All People',
    
    
        initComponent: function() {
    
    
            var imagesUrl =/'+MyApp.util.Globals.projectName+'/'+MyApp.util.Globals.imageFolder;
    
    
    
    
            this.store = {
                fields: ['name', 'email'],
                data  : [
                    {name: 'Ed',    email: 'ed@sencha.com', myVal: 1},
                    {name: 'Tommy', email: 'tommy@sencha.com',myVal: 2}
                ]
            };
    
    
            this.columns = [
                {header: 'Name',  dataIndex: 'name',  flex: 1},
                {header: 'Email', dataIndex: 'email', flex: 1},
                {header: '', dataIndex: 'myVal',
                    renderer: function() {
                        return Ext.String.format('<img src="'+imagesUrl+'/edit.png" />');
                    }
                },
                {header: '', dataIndex: 'myVal',
                    renderer: function() {
                        return '<img src="'+imagesUrl+'/book.png" alt="Lesson Study"/>';
                    }
                },
                {header: '', dataIndex: 'myVal',
                    renderer: function(){
    
    
                        var imageTmpl = Ext.create('MyApp.util.ImageTmpl');
    
    
                        console.log(imageTmpl);
    
    
                        return imageTmpl;
                    }
                }
            ];
    
    
            this.callParent(arguments);
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,116
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Why not use an action column instead?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    12
    Vote Rating
    0
    Tuminh112 is on a distinguished road

      0  

    Default Ext js 4 MVC listeners

    Ext js 4 MVC listeners


    I have the same question but instead of a grid I have an image map with several links in my View. Should the listeners be in the View or Controller?