javascript - Extjs4 selecting grid row value(s)? - Stack Overflow

So selecting grid row value is easy:handler: function(widget, event){rec = grid.getSelectionModel().get

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 ing from store is not in array, so calling array position isnt a option, or? Is there something like getPosition() but position of row(s)?
Any ideas?

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 ing from store is not in array, so calling array position isnt a option, or? Is there something like getPosition() but position of row(s)?
Any ideas?

Share Improve this question edited Dec 25, 2015 at 12:31 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Oct 10, 2011 at 14:12 Davor ZubakDavor Zubak 4,74614 gold badges61 silver badges95 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You should set the "select" event from the Ext.selection.Model (which is probably cell or row). 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)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745007331a4605860.html

相关推荐

  • javascript - Extjs4 selecting grid row value(s)? - Stack Overflow

    So selecting grid row value is easy:handler: function(widget, event){rec = grid.getSelectionModel().get

    14小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信