如何确定 Ext.grid.Panel 在 ExtJS 4 中的选定单元格

How to determine the selected cell of a Ext.grid.Panel in ExtJS 4?

本文关键字:单元格 ExtJS Ext 何确定 grid Panel      更新时间:2023-09-26

如何获取Ext.grid.Panel的选定单元格?在 ExtJS 3 中,可以通过以下方式实现:

grid.getSelectionModel().getSelectedCell()

在分机 4 中有

grid.getSelectionModel().selected

但这只能给我记录。

可能有更直接的方法可以做到这一点,但以下内容似乎对我有用:

grid.view.getCellByPosition(grid.getSelectionModel().getCurrentPosition());

我最终需要用户单击的实际列并发现以下内容:

grid.panel.columns[grid.getSelectionModel().getCurrentPosition().column]

不要忘记申请:

    selType : 'cellmodel'

到您的网格以确保您可以选择单元格!

使用 beforeedit listener 和 context.record 获取所需的行

this.editing = Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 1,
        listeners: {
            beforeedit: function (obj) {
                var MyColumnValue = obj.context.record.get('YourColumnName');
                 // or maybe to clear the value of this cell
                 obj.context.record.set('YourColumnName', null);
        }
      }
 });