2013-10-02 67 views
1

我在我的網格中添加了一個actioncolumn,並且我試圖在推送時獲取網格值。從網格中獲取值

這是我actioncolumn:

xtype: 'actioncolumn', 
width: 30, 
sortable: false, 
menuDisabled: true, 
items: [{ 
    icon: 'images/refresh16x16.png', 
    scope: this, 
    handler: this.onBidHistoryGridlClick 
} 

這是我的聽衆:

onBidHistoryGridlClick: function(record, grid, rowIndex){ 
    alert(grid.getStore().getAt(rowIndex).column_name); 
} 

這行不通。

pic

任何想法?

回答

2

你已經有了監聽器參數中的記錄,使用它!

record.get('column_name') 

你很可能接近用自己的試探性的,但你忘了,你從商店得到的是創紀錄的,而不是原始數據對象。因此,這寧願一直:

grid.getStore().getAt(rowIndex).get('column_name') 

更新

你有你的處理程序的參數錯誤(檢查docs)。這應該是:

onBidHistoryGridlClick: function(view, rowIndex, colIndex, item, e, record){ 
    alert(record.get('column_name')); 
} 
+0

我使用記錄tryed,但我得到一個錯誤:「Uncaught TypeError:Object [object Object] has no method'get'」。有任何想法嗎? – susparsy

+0

修復你的處理程序的參數。查看我的更新。 – rixo

+0

幹得好我的朋友,工作! – susparsy

0

除了@ rixo的答案,你可能需要使用取決於上下文的「數據」屬性(事件處理的回調函數):

   handler: function (grid, rowIndex, colIndex) { 
        var rec = grid.getStore().getAt(rowIndex).data; 
        alert(rec.toSource()); // this only works in Mozilla Firefox 
        var rec_col_val = grid.getStore().getAt(rowIndex).data.col_name; 
        alert(rec_col_val);