2013-10-02 66 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);