Vue Tables 2 - Custom filters

后端 未结 4 945
栀梦
栀梦 2021-02-14 18:26

I\'m trying to use this https://github.com/matfish2/vue-tables-2 with Vue 2.1.8.

And it\'s working perfectly BUT I need to use custom filters to format some fields based

4条回答
  •  清酒与你
    2021-02-14 19:07

    I found this lesson to help me the best. https://github.com/ratiw/vuetable-2-tutorial/wiki/lesson-13

    Summary: You should emit events with vue-events package or compute properties with Vuex (recommended). You want to use the :append-params="moreParams" on vuetable which is a feature of vuetable2 that will append to api-url along with pagination values (separate from these params). I am using Vuex so I make moreParams a computed property of the vuetable. It uses this.$store.getters.moreParams which is my Vuex getter as I have multiple search fields. This is reactive to my Vuex commits from input field handlers.

        computed: {
          moreParams() {
            return this.$store.getters.moreParams
          },
        },
    

    Otherwise you could use a $store.stage.property. I have a watch on moreParams which refreshes the table with the new query:

        watch: {
          moreParams(newVal, oldVal) {
            this.$nextTick(() => {
              this.$refs.vuetable.refresh()
            })
          },
        },
    

提交回复
热议问题