首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Ext JS获取网格的选定行

Ext JS获取网格的选定行
EN

Stack Overflow用户
提问于 2013-07-01 15:20:58
回答 2查看 12.6K关注 0票数 2

someButton单击事件上,我希望在依赖于它的事件处理程序中获得选定的someGridDo something行。我该怎么做呢?我试着用

代码语言:javascript
运行
复制
var index = someGrid.getSelectionModel().getSelection().selectedIndex; 
var index = someGrid.getSelectionModel().getSelection().selected;

这两行代码都返回空对象。

代码语言:javascript
运行
复制
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 }
                ],
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-07-01 15:43:15

这就是你要找的:

代码语言:javascript
运行
复制
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也可以添加其他列。

票数 2
EN

Stack Overflow用户

发布于 2013-07-01 15:40:02

为了使用getSelectionModel,你必须有SelectionModel,所以你必须添加上面的内容。

代码语言:javascript
运行
复制
 <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
  </SelectionModel>

上面的方法适用于RowSelection。如果你想使用checkbox,还有其他的例子。上面的xml取自ext.net。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17399248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档