1

I'm trying to handle click event on the grid cell using the code below:

{
    xtype : 'clearstoregrid',
    name : 'controlGrid',
    hidden : this.hideControlGrid,
    layout : 'fit',
    store : 'ItemsStore',
    columns : [ {
        text : 'Items',
        dataIndex : 'name',
        sortable : false,
        flex : 6,
        listeners: {
            'cellclick': function(iView, iCellEl, iColIdx, iStore, iRowEl, iRowIdx, iEvent) {
                alert('cellclick');
            }
        }
    }

But when I click on the cell, nothing happens. In the browser console I have no errors.

I'm using ExtJS 4.2.

1 Answer 1

1

You need to implement the grid's cellclick event (of course I assume, that 'clearstoregrid' inherits Ext.grid.Panel). Grid columns (Ext.grid.column.Column) do not have cellclick event.

{
    xtype : 'clearstoregrid',
    name : 'controlGrid',
    hidden : this.hideControlGrid,
    layout : 'fit',
    store : 'ItemsStore',
    columns : [ 
        {
        text : 'Items',
        dataIndex : 'name',
        sortable : false,
        flex : 6
        }
    ],
    listeners: {
        'cellclick': function(iView, iCellEl, iColIdx, iStore, iRowEl, iRowIdx, iEvent) {
            alert('cellclick');
        }
    }
}

Example for ExtJS 4.2:

Ext.onReady(function(){

    Ext.QuickTips.init();
    Ext.FocusManager.enable();

    var store = Ext.create('Ext.data.Store', {
        fields: ['id', 'name'],
        data : [
            {"id": 1, "name": "AA name"},
            {"id": 2, "name": "BA name"},
            {"id": 3, "name": "AB name"},
            {"id": 4, "name": "BB name"},
            {"id": 5, "name": "AC name"},
            {"id": 6, "name": "BC name"},
            {"id": 7, "name": "AD name"},
            {"id": 8, "name": "BD name"},
            {"id": 9, "name": "AE name"}
        ]
    });

    Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: store,
        columns: [
            {
            text: 'ID',  
            dataIndex: 'id'
            },
            {
            text: 'Name',  
            dataIndex: 'name'
            }
        ],
        listeners: {
            'cellclick': function(iView, iCellEl, iColIdx, iRecord, iRowEl, iRowIdx, iEvent) {
                alert('cellclick');
            }
        },
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.