首页 > 解决方案 > 如何在 Ext.grid.EditorGridPanel 中制作 selectRow

问题描述

处理使用 ExtJs 3.1.1 编写的项目:

我想在Ext.grid.EditorGridPanelby中选择整行,selectRow()但没有这种方法。

如果我将网格类型更改为Ext.grid.GridPanel一切都会好的。

为什么 的行为Ext.grid.EditorGridPanel不同于Ext.grid.GridPanel?如何选择整行?

我的网格如下:

var grid = new Ext.grid.EditorGridPanel({
        id : 'g',
        store: store,
        trackMouseOver: true,
            ...
});

事件代码是这样的:

Ext.getCmp('g').on('click', function (e) {
    Ext.getCmp('g').getSelectionModel().selectRow(1);

    // this fires error "Uncaught TypeError: 
    //Ext.getCmp(...).getSelectionModel(...).selectRow is not a function"
}) ;

小提琴:https ://fiddle.sencha.com/#fiddle/2n8m&view/

标签: extjsgrid

解决方案


这是线索!您需要重写 RowSelectionModel:

grid = new Ext.grid.EditorGridPanel({
  store: myStore,
  height: 500,
  border: false, frame: false,
  cm: myColumnModel,
  selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),

推荐阅读