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开发者_JAVA技巧 store is not in array, so calling array position isnt a option, or? Is there something like getPosition()
but position of row(s)?
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)
精彩评论