Reputation: 2878
On someButton
click event I want to get the selected row of someGrid
and Do something
in event-handler dependent on that. How can I do that? I tried using
var index = someGrid.getSelectionModel().getSelection().selectedIndex;
var index = someGrid.getSelectionModel().getSelection().selected;
Both of this lines of code return empty objects.
flex: 1,
xtype: 'grid',
style: 'margin: 10px 5px;',
store: 'CL.Store.VendorServiceLimits',
itemId: 'vendorServiceLimitsGrid',
columns: [
{ text: Labels.Vendors.MIN_AMOUNT, dataIndex: 'MinOperationAmount', flex: 1 },
{ text: Labels.Vendors.MAX_AMOUNT, dataIndex: 'MaxOperationAmount', flex: 1 },
{ text: Labels.Vendors.MAX_TRANS_PER_DAY, dataIndex: 'MaxOperationsPerDay', flex: 1 },
{ text: Labels.Vendors.OPERATION_TYPE, dataIndex: 'OperationType', flex: 1 },
{ text: Labels.Vendors.PERIOD, dataIndex: 'Period', flex: 1 },
{ dataIndex: 'Id', hidden: true }
],
Upvotes: 2
Views: 13084
Reputation: 2035
In order for using getSelectionModel
you must have SelectionModel
So you have to add the above.
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
The above is working for RowSelection
. There are other examples if you want to use checkbox.
The above xml is taken from ext.net.
Upvotes: 0
Reputation: 3932
Is is what you are looking for :
listeners:{
click:function(){
var grid = Ext.getCmp('grid');
var selection= grid.getSelectionModel();
items=[];
for(i=0;i < grid.store.getCount();i++){
if(selection.isSelected(i)){
items.push({
"MinOperationAmount" : grid.store.getAt(i).data.MinOperationAmount,
"MaxOperationAmount" : grid.store.getAt(i).data.MaxOperationAmount
});
}
}
}
}
In items array,you will be getting handle to all the selected records.Here i have pushed only two columns data.You can add other columns too.
Upvotes: 2