在someButton
单击事件上,我希望在依赖于它的事件处理程序中获得选定的someGrid
和Do something
行。我该怎么做呢?我试着用
var index = someGrid.getSelectionModel().getSelection().selectedIndex;
var index = someGrid.getSelectionModel().getSelection().selected;
这两行代码都返回空对象。
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 }
],
发布于 2013-07-01 15:43:15
这就是你要找的:
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
});
}
}
}
}
在items数组中,您将处理我只推入了两列的所有选定的records.Here,data.You也可以添加其他列。
发布于 2013-07-01 15:40:02
为了使用getSelectionModel
,你必须有SelectionModel
,所以你必须添加上面的内容。
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
上面的方法适用于RowSelection
。如果你想使用checkbox,还有其他的例子。上面的xml取自ext.net。
https://stackoverflow.com/questions/17399248
复制相似问题