Created
March 17, 2018 11:26
-
-
Save warlord0/0b171baea34058e50c807f578cb29afe to your computer and use it in GitHub Desktop.
Pagination issue with BootstrapVuew
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
<template> | |
<div> | |
<p class="alert alert-info"><i class="fa fa-info-circle"></i> Click on the contract for more detail.</p> | |
<b-table striped hover :items="contracts.data" :fields="fields" | |
:sort-by="sortBy" :sort-desc="sortDesc" no-local-sorting @sort-changed="sortChanged" /> | |
<b-pagination :total-rows="contracts.total" :per-page="contracts.per_page" | |
:limit="6" v-model="contracts.current_page" @change="paginationChange" /> | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
contracts: [], | |
fields: [ | |
{ key: 'ref', sortable: true }, | |
{ key: 'contractName' }, | |
{ key: 'contractValue', sortable: true } | |
], | |
sortBy: 'ref', | |
sortDesc: true , | |
page: 1 | |
} | |
}, | |
created () { | |
this.loadData(); | |
}, | |
methods: { | |
loadData () { | |
axios.get('/api/finance/contractlist', { | |
params: { | |
fields: this.fields.map(field => field.key), | |
sortBy: this.sortBy, | |
sortDesc: this.sortDesc, | |
page: this.page | |
} | |
}) | |
.then(response => { | |
this.contracts = response.data; | |
}) | |
.catch(error => { | |
console.error(error); | |
this.contracts = []; | |
}); | |
}, | |
sortChanged (ctx) { | |
this.sortBy = ctx.sortBy; | |
this.sortDesc = ctx.sortDesc; | |
this.loadData(); | |
}, | |
paginationChange (page) { | |
this.page = page; | |
this.loadData(); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment