Giter Club home page Giter Club logo

Comments (6)

ratiw avatar ratiw commented on May 28, 2024

@thomasdola This is interesting! I've never thought of using it like this. :)
Let me think about it and I'll let you know.

from vue-table.

ratiw avatar ratiw commented on May 28, 2024

@thomasdola
I'm not sure how you set up your code, but if it was me I would do something like this.
I haven't tested this, but the idea is there.

    <vuetable v-ref:regionsTable
        api-url="/api/regions"
        //...
        :item-actions="regionActions"
    ></vuetable>

    <vuetable v-ref:districtsTable
        api-url="/api/districts"
        //...
        :item-actions="districtActions"
        :append-params="districtParams"
    ></vuetable>

    <vuetable v-ref:locationsTable
        api-url="api/locations"
        //...
        :item-actions="locationActions"
        :append-params="locationParams"
    ></vuetable>
new Vue({
    el: '#app',
    data: {
        regionParams: [],
        districtParams: [],
        locationParams: [],
        regionActions: [
            { name: 'select-region', label: '', icon: '...', class: '...' }
        ],
        districtActions: [
            { name: 'select-district', label: '', icon: '...', class: '...' }
        ],
        locationActions: [
        ]
    },
    events: {
        'vuetable:action': function(action, data) {
            if (action == 'select-region') {
                this.districtParams = [
                    'filter=' + data.region
                ]
                this.$nextTick(function() {
                    this.$refs.districtsTable.$broadcast('vuetable:refresh')
                })
            }
            else if (action == 'select-district') {
                this.locationParams = [
                    'filter=' + data.district
                ]
                this.$nextTick(function() {
                    this.$refs.locationsTable.$broadcast('vuetable:refresh')
                })
            }
        },
    }
})

Please note that I'm not quite sure whether to use $broadcast or $dispatch here. If $broadcast does not work, try $dispatch instead and see how it goes.

from vue-table.

thomasdola avatar thomasdola commented on May 28, 2024

this is really cool .
i ll give a try.
thank you

from vue-table.

cloud9business avatar cloud9business commented on May 28, 2024

When I tried this approach $dispatch worked and $broadcast did not.

from vue-table.

xueweiyema avatar xueweiyema commented on May 28, 2024

"this.$refs.districtsTable.$broadcast('vuetable:refresh') "
It can not work.

from vue-table.

ratiw avatar ratiw commented on May 28, 2024

@xueweiyema What's the error? Does $dispatch work?

from vue-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.