ratiw / vuetable-2

data table simplify! -- datatable component for Vue 2.x. See documentation at
https://vuetable.com
MIT License
2.16k stars 399 forks source link

form-data append-params #522

Open Georgeek opened 6 years ago

Georgeek commented 6 years ago

Good day :) I'm having an issue with append-params props. In docs says to use it in case adding search word for examle. It works in GET and i see it in url. But what if I need to put it in Form Data?

Here is example:

// template (pug)
vuetable(ref="vuetable"
              api-url="some_url/datatable"
              :http-fetch="myFetch"
              :append-params="testFn")

// methods
myFetch(apiUrl, httpOptions) {
      let pageParams = httpOptions.params;

      //dataFunc is a fn with New FormData()
      let data = dataFunc({
        'per_page': pageParams.per_page,
        'current_page': pageParams.page,
        'sort': pageParams.sort
      });

// i want to send filter text in form data and update table after response
testFn() {
this.test = {
      global: this.someText
 }
let data = dataFunc();
data.append(this.test)
      this.$nextTick( () => this.$refs.vuetable.refresh())

is there any way to add and send updated formData to server?

ratiw commented 6 years ago

@Georgeek http-fetch only pass you the apiUrl and httpOptions. You have to use the http library of your choice to do the AJAX request. If you use axios, you will have to call axios.get(apiUrl, httpOptions) to get the Promise and handle it appropriately. In order to pass other formData, you should be able to find some examples on axios documentation.