【发布时间】:2015-08-31 16:00:47
【问题描述】:
我需要一种方法,只允许用户使用 handsontable 选择一行或一列(或多选整行和整列)。
【问题讨论】:
-
永恒的问题,你试过什么?
-
我已经回答了我自己的问题 :) 我认为分享一下会很好。
标签: javascript jquery handsontable
我需要一种方法,只允许用户使用 handsontable 选择一行或一列(或多选整行和整列)。
【问题讨论】:
标签: javascript jquery handsontable
经过一些研究和实验,我能够在没有单元格和行句柄的情况下实现单行突出显示。
Handsontable 选项:
var x = new Handsontable(element, {
...
multiSelect: false,
disableVisualSelection: ['current', 'area'],
currentRowClassName: 'currentRow'
}
CSS:
.currentRow, .highlight {
background-color: lightblue;
}
【讨论】:
有一种方法可以通过设置选择多个单元格、范围单元格甚至单个单元格:selectionMode='multiple' 查看此链接:https://docs.handsontable.com/pro/3.0.0/Options.html#selectionMode
【讨论】:
我最终得到了这个解决方案:
beforeOnCellMouseDown: function restrictSelectionToWholeRowColumn(event, coords) {
if(coords.row >= 0 && coords.col >= 0) event.stopImmediatePropagation();
}
像魅力一样工作!
【讨论】: