ExtJS 4 - 网格 - 禁用特定列的行选择 [英] ExtJS 4 - Grid - Disable rowselection for specific column

查看:195
本文介绍了ExtJS 4 - 网格 - 禁用特定列的行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个网格与extjs 4. selection.CheckboxModel实现。这意味着无论您在特定行上单击哪一行,都将选中/取消选择该行。现在我想在最后一列禁用此选择,因为它包含自定义按钮。 (我不希望在点击按钮时选择该行。)

I have created a grid with extjs 4. The selection.CheckboxModel is implemented to. This means that the row is selected/deselected wherever you click on the particular row. Now i want to disable this selection on the last column since it contains custom buttons. (I don't want to select the row if a button is clicked).

任何想法怎么做?

提前非常感谢!

推荐答案

这实际上是一个棘手的小问题,如果只是因为Sencha文档缺乏。

This is actually a tricky little problem, if only because Sencha documentation is lacking.

CheckboxModel确实具有从继承的 beforeselect 事件Ext.selection.RowModel 。但是,没有简单的方法来获取列索引,因为坦率地说,这是RowModel的点。

The CheckboxModel does indeed have a beforeselect event inherited from Ext.selection.RowModel. However, there's no easy way to get the column index because frankly, that's the point of the RowModel.

但是,在 Ext中有一个未记录的事件.view.Table (您的网格将继承) beforecellmousedown 。以下是事件参数:

However, there's an undocumented event in Ext.view.Table (which your grid will inherit) called beforecellmousedown. Here's the event parameters:


  1. 查看:您的网格视图

  2. cell:

  3. cellIndex:单元索引

  4. record:与单元格相关联的商店记录
  5. row:单元格行
  6. rowIndex:行的索引

  7. eOpts:标准事件选项事件

  1. view: The view of your grid
  2. cell: The cell that was clicked
  3. cellIndex: Index of the cell
  4. record: The store record associated with the cell
  5. row: The row of the cell
  6. rowIndex: Index of the row
  7. eOpts: Standard event option event

所以你可能会尝试这样:

So you would probably try something like this:

viewConfig: {
    listeners: {
        beforecellmousedown: function(view, cell, cellIdx, record, row, rowIdx, eOpts){
            if(cellIdx === indexOfLastColumnInGrid){
                return false;
            }
        }
    }
}



单元格和行索引为零。

Both the cell and row indexes are zero-based.

这篇关于ExtJS 4 - 网格 - 禁用特定列的行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆