Skip to content

QTable: Emit an event on col sort #17550

Discussion options

You must be logged in to vote

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.

<q-table
  @update:pagination="onPagination"
...

<script setup>
function onPagination({ sortBy, descending }) {
  console.log({ sortBy, descending })
}
</script>

Alternatively, you can use v-model:pagination to keep it in sync, then use watch to check if it has been changed:

<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, d…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by metalsadman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants