ExtJS 4 - 网格 - 禁用特定列的行选择 [英] ExtJS 4 - Grid - Disable rowselection for specific column
问题描述
我已经创建了一个网格与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确实具有从继承的
。但是,没有简单的方法来获取列索引,因为坦率地说,这是RowModel的点。 beforeselect
事件Ext.selection.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:
- 查看:您的网格视图
- cell:
- cellIndex:单元索引
- record:与单元格相关联的商店记录 row:单元格行
- rowIndex:行的索引
- eOpts:标准事件选项事件
- view: The view of your grid
- cell: The cell that was clicked
- cellIndex: Index of the cell
- record: The store record associated with the cell
- row: The row of the cell
- rowIndex: Index of the row
- 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屋!