Skip to content

Commit

Permalink
Merge pull request lusaxweb#283 from brunokunace/feature/reactive_max…
Browse files Browse the repository at this point in the history
…_prop_table

added watch on max-items for reactive data
  • Loading branch information
luisDanielRoviraContreras committed Oct 7, 2018
2 parents a94eb09 + 1ca0f8a commit 4c450ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/components/vsPagination/vsPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export default {
current() {
this.getPages()
this.$emit('input', this.current)
},
total() {
this.getPages()
}
},
Expand Down Expand Up @@ -137,7 +140,6 @@ export default {
let pages = this.setPages(1, this.total)
this.pages = pages
}
// console.log('this.total', this.total)
const even = this.max % 2 === 0 ? 1 : 0
if(this.total < 6) {
this.prevRange = Math.floor(this.max / (this.max/2))
Expand Down
26 changes: 12 additions & 14 deletions src/components/vsTable/vsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,15 @@ export default {
},
watch:{
currentx() {
let max = Math.ceil(this.currentx * this.maxItems)
let min = max - this.maxItems
this.datax = this.getItems(min, max)
this.loadData()
},
maxItems() {
this.loadData()
},
data() {
let max = Math.ceil(this.currentx * this.maxItems)
let min = max - this.maxItems
let datax = this.pagination ? this.getItems(min, max) : this.data
this.datax = datax || []
this.loadData()
this.$nextTick(() => {
if(datax.length > 0) {
if(this.datax.length > 0) {
this.changeTdsWidth()
}
})
Expand All @@ -182,10 +177,8 @@ export default {
mounted () {
window.addEventListener('resize', this.listenerChangeWidth)
let max = Math.ceil(this.currentx * this.maxItems)
let min = max - this.maxItems
this.loadData()
this.datax = this.pagination ? this.getItems(min, max) : this.data || []
this.$nextTick(() => {
if(this.datax.length > 0) {
this.changeTdsWidth()
Expand All @@ -196,6 +189,11 @@ export default {
window.removeEventListener('resize', this.listenerChangeWidth)
},
methods:{
loadData() {
let max = Math.ceil(this.currentx * this.maxItems)
let min = max - this.maxItems
this.datax = this.pagination ? this.getItems(min, max) : this.data || []
},
getItems(min, max) {
let items = []
Expand Down

0 comments on commit 4c450ef

Please sign in to comment.