简体   繁体   中英

Get Grid Cell Value on Hover in ExtJS4

I have the following code in a grid:

    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        stateful: true,
        stateId: 'stateGrid',
        columns: [
            {
                text     : 'Job ID',
                width : 75,
                sortable : true,
                dataIndex: 'id'
            },
            {
                text     : 'File Name',
                width    : 75,
                sortable : true,
                dataIndex: 'filename', 
                listeners : {
                    'mouseover' : function(iView, iCellEl, 
                                  iColIdx, iRecord, iRowEl, iRowIdx, iEvent) {
                       var zRec = iView.getRecord(iRowEl);
                       alert(zRec.data.id);
                    }
                }

...etc...

I can't figure out how to get the cell value of the first column in the row. I've also tried:

        var record = grid.getStore().getAt(iRowIdx); // Get the Record
        alert(iView.getRecord().get('id'));

Any ideas?

Thanks in advance!

It's easier than what you have.

Look at the Company column config here for an example- http://jsfiddle.net/qr2BJ/4580/

Edit:

Part of grid definition code:

....
columns: [
    {
        text     : 'Company',
        flex     : 1,
        sortable : false,
        dataIndex: 'company',
        renderer : function (value, metaData, record, row, col, store, gridView) {
            metaData.tdAttr = 'data-qtip="' + record.get('price') + ' is the price of ' + value + '"';
            return value;
        }
    },
    ....

You can add a handler instead of a listener.

{
    header: 'DETAILS',
    xtype:'actioncolumn', 
    align:'center', 
    width: 70, 
    sortable: false, 
    items: [
        {
            icon: '/icons/details_icon.png',  // Use a URL in the icon config
            tooltip: 'Show Details',    
            handler: function(grid, rowIndex, colIndex) {
                var record = grid.getStore().getAt(rowIndex);
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM