问题描述
我用 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).
知道如何做到这一点吗?
Any idea's how to do this?
非常感谢!
推荐答案
这实际上是一个棘手的小问题,如果只是因为缺少 Sencha 文档.
This is actually a tricky little problem, if only because Sencha documentation is lacking.
CheckboxModel 确实有一个从 Ext.selection.RowModel
继承的 beforeselect
事件.但是,获取列索引并不容易,因为坦率地说,这就是 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:
- view:网格视图
- cell:被点击的单元格
- cellIndex:单元格索引
- record:与单元格关联的商店记录
- row:单元格所在的行
- rowIndex:行的索引
- eOpts:标准事件选项事件
所以你可能会尝试这样的事情:
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 - 网格 - 禁用特定列的行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!