简体   繁体   English

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

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

how can i get the selected cell of a Ext.grid.Panel? 我怎样才能获得Ext.grid.Panel的选定单元格? In ExtJS 3 it was possible via: 在ExtJS 3中,有可能通过:

grid.getSelectionModel().getSelectedCell()

In Ext 4 there is 在Ext 4中有

grid.getSelectionModel().selected

but this only gives me the record. 但这只给了我记录。

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

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

I ended up needing the actual column that the user was clicking on and discovered the following: 我最终需要用户点击的实际列并发现以下内容:

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

Don't forget to apply: 不要忘记申请:

    selType : 'cellmodel'

to your grid to make sure you can select cells! 到您的网格,以确保您可以选择单元格!

Use the beforeedit listener and context.record to get the desired row 使用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);
        }
      }
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM