VTable
VTable copied to clipboard
[Feature] 希望可以禁止拖拽选中多个单元格,只想要点击选中单个单元格
What problem does this feature solve?
What does the proposed API look like?
希望可配置点击选中整行
#1068
希望可配置点击选中整行
目前我是这样实现的,点击每行第一个单元格选中整行
...
table.on('selected_cell', params => onTableSelected(params, table))
...
function onTableSelected(params: TYPES.SelectedCellEvent, table: ListTable) {
const { ranges } = params
const indexColumns = getOnlyIndexColumnRanges(ranges)
indexColumns.forEach(({ start }) => {
selectOneRow(start.row)
})
const newRanges = table.getSelectedCellRanges()
currentSelected.ranges = newRanges
}
function getOnlyIndexColumnRanges(
ranges: TYPES.CellRange[],
): TYPES.CellRange[] {
return ranges.filter(({ start, end }) => start.col === 0 && end.col === 0)
}
function selectOneRow(rowIndex: number) {
tableInstance?.selectCells([
{
start: { row: rowIndex, col: 0 },
end: { row: rowIndex, col: columns.value.length - 1 },
},
])
}
但是视觉上还是会先选中点击的格子,然后才选中整行。尝试使用 click_cell 事件,却发现点击事件竟然在选择事件后面触发,无法阻止选中事件。
https://github.com/VisActor/VTable/pull/2312
1.7.0 已经支持配置disableDragSelect