QTable: Emit an event on col sort #17550
Answered
by
yusufkandemir
nlassaux
asked this question in
General - Components / Directives / etc
-
Hi there! I'm trying to detect when a column has been sorted by a user. I was expecting an event for it, but I can't seem to find any. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
yusufkandemir
Oct 1, 2024
Replies: 1 comment
-
You can use <q-table
@update:pagination="onPagination"
...
<script setup>
function onPagination({ sortBy, descending }) {
console.log({ sortBy, descending })
}
</script> Alternatively, you can use <q-table
v-model:pagination="pagination"
...
<script setup>
const pagination = ref({})
watch(
[() => pagination.value.sortBy, () => pagination.value.descending],
([sortBy, descending], [oldSortBy, oldDescending]) => {
console.log({ sortBy, descending })
}
)
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
metalsadman
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
@update:pagination
, but it won't only be triggered on sorting changes. You can use a separate variable to check if it was changed, if you need such logic.Alternatively, you can use
v-model:pagination
to keep it in sync, then usewatch
to check if it has been changed: