matfish2 / vue-tables

Vue.js grid components
https://www.npmjs.com/package/vue-tables
MIT License
357 stars 76 forks source link

make parameter names of server table configurable #68

Closed asmaps closed 8 years ago

asmaps commented 8 years ago

The reply of my API (Django REST Framework default) looks like this:

{   
    "count": 684,
    "next": "http://.../?limit=50&offset=50",
    "previous": null,
    "results": [
         { "foo": "bar" },
         { "foo": "baz" },
    ]
}

so I needed an option to change in which field the server table looks for the objects (in this case results instead of data). In this PR I added that feature. I hope you find it useful.

asmaps commented 8 years ago

Usage:

Vue.use(VueTables.server, {
   serverDataFieldName: 'results',
})
asmaps commented 8 years ago

I also added another commit that makes the query parameters configurable.

TODO: Update the jsfiddle with the options documentation

matfish2 commented 8 years ago

Honestly, I am not a big fan of the idea of "bending" the API towards the consumer. In case the response from a remote API almost matches the plugin's requirements by accident, one is welcome to fork the repo and change whatever keys he needs. See PR #38.

As for the params issue, vue-resource had a breaking change in version 0.9.0, which, as the documentation states, is the minimum version required. I suppose you are using an older version, which explains why everything is wrapped with the params property. See Issue #64.

blodone commented 8 years ago

+1 for making it in base flexbile