Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Ext JS get grid';s选定的行_Extjs_Grid - Fatal编程技术网

Extjs Ext JS get grid';s选定的行

Extjs Ext JS get grid';s选定的行,extjs,grid,Extjs,Grid,在someButton上单击事件,我想获取someGrid的选定行,并根据该行在事件处理程序中执行操作。我该怎么做?我试着用 var index = someGrid.getSelectionModel().getSelection().selectedIndex; var index = someGrid.getSelectionModel().getSelection().selected; 这两行代码都返回空对象 flex: 1, xtype: 'gri

someButton
上单击事件,我想获取
someGrid
的选定行,并根据该行在事件处理程序中执行操作。我该怎么做?我试着用

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 }
                ],

要使用
getSelectionModel
您必须具有
SelectionModel
因此,您必须添加上述内容

 <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
  </SelectionModel>

以上内容适用于
行选择
。如果要使用复选框,还有其他示例。
上面的xml取自ext.net

是您正在寻找的:

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
             });
      }
    }
 }
}
侦听器:{
单击:函数(){
var grid=Ext.getCmp('grid');
var selection=grid.getSelectionModel();
项目=[];
对于(i=0;i

在items数组中,您将获得所有选定记录的句柄。这里我只推送了两列数据。您也可以添加其他列

请提供网格的代码。正如我看到的,您是动态创建的。因此,您需要创建如下内容:能否将
store.indexOf(record)
selModel.getSelection()结合使用?i、 e.
store.indexOf(grid.getSelectionModel().getSelection()[0])
@kevhender+用于
grid.getSelectionModel().getSelection()[0]
提醒的道具。当我来这里的时候,我正试图很快找到它。这会有用,但太贵了。我的意思是我只想得到一个数字,它将指示所选网格的行。grid有一个名为cellclick的事件,它接收名为rowIndex的参数。这就是我要找的!但是我不想用点击事件来处理我想做的事情。我想改为使用按钮单击事件