OneWayTech / vue2-datatable

(DEPRECATED) The best Datatable for Vue.js 2.x which never sucks. Give us a star 🌟 if you like it!
MIT License
881 stars 230 forks source link

Feature request #5

Closed fatb0000 closed 7 years ago

fatb0000 commented 7 years ago

Hi, Thanks for your quick response for #4 .will respsonive table be supported? Or I can do something to make vue2-datatable responsive?

kenberkeley commented 7 years ago

It's already responsive, see: https://github.com/OneWayTech/vue2-datatable/blob/master/lib/index.vue#L10

fatb0000 commented 7 years ago

thanks. I mean like datatables one: https://datatables.net/extensions/responsive/examples/child-rows/column-control.html when the screen size < XXXpx , it will be collapse

kenberkeley commented 7 years ago

Oh i see. Here is an example:

import throttle from 'lodash/throttle'

mounted () {
  const $win = $(window)

  $win.on('resize', throttle(() => {
    let curWidth = $win.width()
    let fieldsToHide

    if (curWidth < 500) {
      fieldsToHide = ['aaa', 'bbb', 'ccc']
    } else if (curWidth < 1000) {
      fieldsToHide = ['xxx', 'yyy', 'zzz']
    } else {
      // no fields to hide
    }

    if (fieldsToHide) {
      this.columns.forEach(col => {
        if (fieldsToHide.includes(col.field)) {
          this.$set(col, 'visible', false)
        }
      })
    }
  }, 200))
}
anit05 commented 6 years ago

Hi @kenberkeley can you guide me about how responsiveness works and one more thing, https://github.com/OneWayTech/vue2-datatable/blob/master/lib/index.vue#L10 is not working

Thanks

kenberkeley commented 6 years ago

@anit05 This datatable is not responsive...