简体   繁体   English

Extjs4选择网格行值?

[英]Extjs4 selecting grid row value(s)?

So selecting grid row value is easy: 因此,选择网格行值很容易:

handler: function(widget, event){
    rec = grid.getSelectionModel().getSelection()[0];
    console.log(rec.get('amount') + rec.get("price"));
}

This way, when user interacts with grid it simply retrieves data from its scope, my question is how to retrieve specific data from specific rows? 这样,当用户与网格交互时,它只是从其范围中检索数据,我的问题是如何从特定行检索特定数据? Lets say user clicks on third row from the top, how to select data from third, second and firs row, or fourth and firs(random)? 让我们说用户点击顶部的第三行,如何从第三,第二和第一行,或第四和第一(随机)中选择数据? I belive data coming from store is not in array, so calling array position isnt a option, or? 我相信来自商店的数据不在数组中,所以调用数组位置不是一个选项,或者? Is there something like getPosition() but position of row(s)? 是否有类似getPosition()但行的位置? 在此输入图像描述
Any ideas? 有任何想法吗?

You should set the "select" event from the Ext.selection.Model (which is probably cell or row). 您应该从Ext.selection.Model(可能是单元格或行)设置“select”事件。 In that event you receive as parameters: 在那种情况下,您会收到以下参数:

Ext.selection.RowModel: select( Ext.selection.RowModel this, Ext.data.Model record, Number index, Object eOpts ).

So from there you have the record as well as the index, if you want to get another record (for example the previous one) you should get it from the store like so: 所以从那里你有记录和索引,如果你想获得另一条记录(例如前一条记录),你应该从商店得到它,如下所示:

record.store.getAt(index - 1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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