From 0163a079dd4ed2adce15921c7c394bbf31199e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=B3pez=20C?= Date: Mon, 2 Dec 2024 10:40:23 -0500 Subject: [PATCH 1/6] add props onSelect, function handleRowSelect and onClick event --- src/runtime/components/Table.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue index 809dfc4119..c712b45e18 100644 --- a/src/runtime/components/Table.vue +++ b/src/runtime/components/Table.vue @@ -58,6 +58,7 @@ export interface TableProps { * @defaultValue false */ sticky?: boolean + onSelect?: (e: Event, row: T) => void /** Whether the table should be in loading state. */ loading?: boolean loadingColor?: TableVariants['loadingColor'] @@ -197,6 +198,13 @@ function valueUpdater>(updaterOrValue: T, ref: Ref) { ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue } +function handleRowSelect(e: Event, row: Row) { + if (!props.onSelect) + return + e.preventDefault() + row.toggleSelected(!row.getIsSelected()) + props.onSelect(e, row.original) +} defineExpose({ tableApi }) @@ -229,7 +237,7 @@ defineExpose({