20260715173700

This commit is contained in:
oneao committed 2026-07-15 17:37:01 +08:00
1 parent bf7b3259bc
commit 7049584d1e
366 files changed
+157207

No files matched your search

@@ -0,0 +1,42 @@
export function processGridKeydown(event, $table) {
if (!$table) {
return;
}
const currentRow = $table.getCurrentRecord();
const currentRowIndex = $table.getRowIndex(currentRow);
const currentColumn = $table.getCurrentColumn();
const { key } = event;
// 获取表格的所有数据和列配置
const fullData = $table.getFullData();
const columns = $table.getColumns();
const currentColumnIndex = $table.getColumnIndex(currentColumn);
// ArrowUp - 向上移动一行
if (key === "ArrowUp" && currentRowIndex > 0) {
const toIndex = currentRowIndex - 1;
$table.setEditRow(fullData[toIndex], currentColumn.property);
$table.setCurrentRow(fullData[toIndex]);
}
// ArrowDown - 向下移动一行
else if (key === "ArrowDown" && currentRowIndex < fullData.length - 1) {
const toIndex = currentRowIndex + 1;
$table.setEditRow(fullData[toIndex], currentColumn.property);
$table.setCurrentRow(fullData[toIndex]);
}
// ArrowLeft - 向左移动一列
else if (key === "ArrowLeft" && currentColumnIndex > 0) {
const toIndex = currentColumnIndex - 1;
$table.setEditCell(currentRow, columns[toIndex]);
$table.setCurrentColumn(columns[toIndex]);
}
// ArrowRight || Enter - 向右移动一列
else if ((key === "ArrowRight" || key === "Enter") && currentColumnIndex < columns.length - 1) {
event.preventDefault();
const toIndex = currentColumnIndex + 1;
$table.setEditCell(currentRow, columns[toIndex]);
$table.setCurrentColumn(columns[toIndex]);
}
}