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

Managing moreParams for queries #98

Closed scottgrayson closed 8 years ago

scottgrayson commented 8 years ago

I have been following your bootstrap example: https://github.com/ratiw/vuetable-example-vueify-bootstrap/blob/master/index.js#L112 If i am not mistaken, this code will overwrite any values in moreParams[] that you have set before the filter.

<vuetable :append-params="moreParams" >
        setFilter: function() {
            this.moreParams = [
                'filter=' + this.searchFor
            ]
            this.$nextTick(function() {
                this.$broadcast('vuetable:refresh')
            })
        },

Would it be possible to make :append-params accept { key: value } instead of ['key=value']? This would make updates easier.

I have tried making moreParams a computed property to resolve my problem, but the values in vue dev tools and the values appended to http params do not match. Is using a computed property for :append-params not supported? I can provide the computed property code if necessary.

scottgrayson commented 8 years ago

Solution <vuetable :http-data:"moreParams">

allows moreParams to be an object and it does not overwrite any existing vuetable params like pagination or sort.

example object:

moreParams: {
    searchFor: '',
    comps_only: 'true',
}

This is useful information IMO. it could be added here: https://github.com/ratiw/vue-table/wiki/Appending-Other-Parameters-to-the-Query-String

ratiw commented 8 years ago

@scottgrayson In version 2.0 of vuetable that I'm currently working, the append-params type has actually been changed from Array to Object.

In version 1.x of vuetable, I'm trying to avoid any breaking change until version 2.0 is released at the moment, unless it's really necessary. That's why it's still there.