ratiw / vue-table

data table simplify! -- vuetable is a Vue.js component that will automatically request (JSON) data from the server and display them nicely in html table with swappable/extensible pagination component.
MIT License
1.83k stars 303 forks source link

'Per page' dropdown #147

Open marekkaczkowski opened 7 years ago

marekkaczkowski commented 7 years ago

I figured out that VuetablePaginationDropdown is actually dropdown with pages not a pagination win 'Per page' dropdown :confused: so I'm trying to add little component that will change perPage value. I'm changing per_page in moreParams but I feel it's not the right way

    onChangePerPage (event) {
      this.moreParams.per_page = Number(event.target.value)
      Vue.nextTick(() => this.$refs.vuetable.refresh())
    }

Can you give some tips on it? :wink:

ratiw commented 7 years ago

@marekkaczkowski It's in the example here

lmj0011 commented 7 years ago

@marekkaczkowski

put perPage in your data function and then add a watcher

https://github.com/ratiw/vue-table/blob/master/examples/semantic.html#L344-L351

     <div>
          <label>Per Page:</label>
          <select class="ui simple dropdown" v-model="perPage">
            <option value=10>10</option>
            <option value=15>15</option>
            <option value=20>20</option>
            <option value=25>25</option>
            <option value=50>50</option>
            <option value=100>100</option>
            <option value=250>250</option>
          </select>
        </div>
      </div>
data () {
      return {
        // [...]
        perPage: 10,
      }
    },
watch: {
      'perPage': function(val, oldVal) {
          Vue.nextTick( () => this.$refs.vuetable.refresh())
      },
    }