簡體   English   中英

在ExtJS4中懸停獲取網格單元格值

[英]Get Grid Cell Value on Hover in 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'));

有任何想法嗎?

提前致謝!

它比您擁有的要容易。

在此處查看“ 公司”列配置以獲取示例-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;
        }
    },
    ....

您可以添加處理程序而不是偵聽器。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM