Skip to content

Instantly share code, notes, and snippets.

@christian-smith
Last active October 20, 2020 05:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save christian-smith/d93b80516d707b7af0e9bf07faeda25e to your computer and use it in GitHub Desktop.
Save christian-smith/d93b80516d707b7af0e9bf07faeda25e to your computer and use it in GitHub Desktop.
<q-table
:data="data"
:pagination="pagination"
@request="paginationRequest"
:columns="columns"
>
<template v-slot:top-left="topLeft">
<TablePagination :pagination="topLeft.pagination" @request="paginationRequest" />
</template>
</q-table>
import Vue from 'vue'
import ListenersMixin from 'quasar/src/mixins/listeners.js'
import Bottom from 'quasar/src/components/table/table-bottom'
import Pagination from 'quasar/src/components/table/table-pagination'
export default Vue.extend({
mixins: [
Bottom,
ListenersMixin,
Pagination
],
data () {
return {
innerPagination: Object.assign(
{
sortBy: null,
descending: false,
page: 1,
rowsPerPage: this.rowsPerPageOptions.length > 0 ? this.rowsPerPageOptions[0] : 5
},
this.pagination
)
}
},
computed: {
computedRowsNumber () {
return this.pagination.rowsNumber
},
isServerSide () {
return this.computedPagination.rowsNumber !== undefined
}
},
methods: {
requestServerInteraction (prop = {}) {
this.$nextTick(() => {
this.$emit('request', {
pagination: prop.pagination || this.computedPagination
})
})
}
},
render (h) {
const bottom = h('div', [
this.__getBottomDiv(h)
])
// removes horizontal line
bottom.children[0].data.staticClass = 'row items-center justify-end'
return bottom
}
})
@ajcastro
Copy link

This is great. Thanks for this. Btw I tweak the gist to accomodate those with filters:
https://gist.github.com/ajcastro/83af279e7d7540f82cae791d9bd430f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment