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

我只是一个虾纸丫 提交于 2019-12-23 18:05:47

问题


how can i get the selected cell of a Ext.grid.Panel? In ExtJS 3 it was possible via:

grid.getSelectionModel().getSelectedCell()

In Ext 4 there is

grid.getSelectionModel().selected

but this only gives me the record.


回答1:


There may be a more direct way to do this but the following seems to work for me:

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



回答2:


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!




回答3:


Use the beforeedit listener and context.record to get the desired row

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);
        }
      }
 });


来源:https://stackoverflow.com/questions/6042176/how-to-determine-the-selected-cell-of-a-ext-grid-panel-in-extjs-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!