Results 1 to 3 of 3

Thread: renderer in Column Model

  1. #1

    Lightbulb renderer in Column Model

    Hello,
    I'm new with Ext JS and I have one question. In a column I'm displaying an image (which it works), but I want that image to call a function when it is clicked. The function sayHello(), is declared above the column model. When I click on the image in my grid, I get an error saying that the sayHello function is not defined. I'll appreciate any help with this. Thanks.
    Code:
    function sayHello(){
    alert("Hello");
    }; var columnModel = ([ { header : 'Actions', dataIndex : 'actions', renderer: function(v, params, record){ return "<img src='resources/images/customers_icon.gif' qtip='View customers' onclick=\"sayHello();\" /> "; }, //id : 'firstName', //sortable : true, hideable : false, width : 75 } ]);

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Ah globals. not cool!

    try window.sayHello = function(){}.

  3. #3
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153

    Default

    Don't use inline onclick event handler, try this:
    Code:
    var columnModel = ([
    {
                header : 'Actions',
                dataIndex : 'actions',
                renderer: function(v, params, record){
                    return "<img src='resources/images/customers_icon.gif' class="someClass" qtip='View customers'/> ";
                },
                //id : 'firstName',
                //sortable : true,
                hideable : false,
                width : 75
            }
    ]);
    
    yourGrid.on('cellclick', function(g, row, col, e) {
        if (e.getTarget('.someClass')) {
            alert('Hello');
        }
    });

Similar Threads

  1. Ampersand in column model doesnt show in column header menulist?
    By aolee in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Apr 2010, 2:31 AM
  2. Issue using a model object for pagination and defining a cell renderer
    By dmanchikalapudi in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 13 Apr 2010, 9:31 AM
  3. Loading data store in column model renderer function
    By ferr in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 21 Jul 2008, 8:07 PM
  4. Grid - Renderer in column model - refreshing?
    By ronmichael in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 11 Jul 2008, 5:54 AM
  5. Multiple renderer in Grid Column model
    By smruti_patra in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 7 May 2008, 12:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •