How do I preserve the pagination state when I click a link on the table to a new view then click back in the browser? Vue Tables 2 always goes back to page 1 when I click back.
I have Vue.use(ServerTable, {preserveState: true}) set when init the plugin and I am using Vue Router with history set to true.
Okay so I ended up doing the following to work successfully with Laravel pagination and Vue-Tables-2.
created () {
var url = new URL(window.location.href)
var pageNumber = url.searchParams.get("page")
if(!!pageNumber) {
this.options = {...this.options, initialPage: pageNumber}
}
}
and then
methods: {
paginationChanged() {
console.log("Pagination did change...")
var url = new URL(window.location.href)
url.searchParams.set("page", this.$refs.quotesTable.Page)
window.history.replaceState({}, null, url.href)
this.options = {...this.options, initialPage: this.$refs.quotesTable.Page}
},
}
}
data () {
const vm = this
return {
columns: [],
options: {}
}
}
and the top of the server template
<v-server-table ref="quotesTable" :columns="columns" :options="options" @pagination="paginationChanged">
Hope this helps anyone else using Laravel and this plugin.
Pagination should be preserved when using preserveState: true, I will look into it
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Most helpful comment
Okay so I ended up doing the following to work successfully with Laravel pagination and Vue-Tables-2.
and then
and the top of the server template
Hope this helps anyone else using Laravel and this plugin.