-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Table): add click event for the entire row (#353)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
- Loading branch information
1 parent
31d571a
commit d292706
Showing
4 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
docs/components/content/examples/TableExampleClickable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script setup> | ||
const people = [{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
title: 'Front-end Developer', | ||
email: 'lindsay.walton@example.com', | ||
role: 'Member' | ||
}, { | ||
id: 2, | ||
name: 'Courtney Henry', | ||
title: 'Designer', | ||
email: 'courtney.henry@example.com', | ||
role: 'Admin' | ||
}, { | ||
id: 3, | ||
name: 'Tom Cook', | ||
title: 'Director of Product', | ||
email: 'tom.cook@example.com', | ||
role: 'Member' | ||
}, { | ||
id: 4, | ||
name: 'Whitney Francis', | ||
title: 'Copywriter', | ||
email: 'whitney.francis@example.com', | ||
role: 'Admin' | ||
}, { | ||
id: 5, | ||
name: 'Leonard Krasner', | ||
title: 'Senior Designer', | ||
email: 'leonard.krasner@example.com', | ||
role: 'Owner' | ||
}, { | ||
id: 6, | ||
name: 'Floyd Miles', | ||
title: 'Principal Designer', | ||
email: 'floyd.miles@example.com', | ||
role: 'Member' | ||
}] | ||
function select (row) { | ||
const index = selected.value.findIndex((item) => item.id === row.id) | ||
if (index === -1) { | ||
selected.value.push(row) | ||
} else { | ||
selected.value.splice(index, 1) | ||
} | ||
} | ||
const selected = ref([people[1]]) | ||
</script> | ||
|
||
<template> | ||
<UTable v-model="selected" :rows="people" @select="select" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d292706
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ui – ./
ui-git-dev-nuxtlabs.vercel.app
ui-nuxtlabs.vercel.app
ui.nuxtlabs.com