VTable icon indicating copy to clipboard operation
VTable copied to clipboard

[Feature] 希望可以禁止拖拽选中多个单元格,只想要点击选中单个单元格

Open Rui-Sun opened this issue 1 year ago • 3 comments

What problem does this feature solve?

What does the proposed API look like?

Rui-Sun avatar Jan 17 '24 04:01 Rui-Sun

希望可配置点击选中整行

nikoohp avatar Jan 17 '24 07:01 nikoohp

#1068

fangsmile avatar Jun 27 '24 07:06 fangsmile

希望可配置点击选中整行

目前我是这样实现的,点击每行第一个单元格选中整行

...
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 事件,却发现点击事件竟然在选择事件后面触发,无法阻止选中事件。

kortin99 avatar Jul 16 '24 03:07 kortin99

https://github.com/VisActor/VTable/pull/2312

fangsmile avatar Sep 10 '24 02:09 fangsmile

1.7.0 已经支持配置disableDragSelect

fangsmile avatar Sep 10 '24 02:09 fangsmile