2011-11-17 36 views
2

我有一個網格下面的代碼:獲取網格單元格數值懸停在ExtJS4

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); 
        } 
       } 

...等...

我無法弄清楚如何獲取單元格的值該行中的第一列。我也試過:

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

任何想法?

在此先感謝!

+1

我覺得你非常親密。嘗試'alert(record.get('id'));'而不是'iView.getRecord ...' – Hemlock

回答

6

它比你擁有的容易。

看那公司列配置這裏的示例 - http://jsfiddle.net/qr2BJ/4580/

編輯:

的網格定義的代碼部分:

.... 
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; 
     } 
    }, 
    .... 
+0

感謝您的幫助! – maximus

0

您可以添加一個處理程序,而不是的聽衆。

{ 
    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); 
      }