niiknow / vue-datatables-net

Vue jQuery DataTables.net wrapper component
https://niiknow.github.io/vue-datatables-net/
MIT License
171 stars 58 forks source link

Dynamic ajax data #80

Closed ghost closed 1 year ago

ghost commented 1 year ago

In my table options i have ajax: { url: 'backend/test', data: { name: this.nameFilter } }

when i do

console.log(this.$refs.table.opts.ajax.data) or console.log(this.$refs.table.dataTable.ajax.data)

they both show the value changing yet the value its not sending when using this.$refs.table.reload()

i also tried assigning the values this way:

this.$refs.table.opts.ajax.data = { 'name' : this.nameFilter }

and

this.$refs.table.dataTable.ajax.data = { 'name' : this.nameFilter }

with the same exact results

I think im missing something how should i approach it?

ghost commented 1 year ago

I got it to work by using data as a function like this

let filter = this.nameFilter
ajax: {
                    url: "/repuestos/datatable",
                        data: function (data) {
                        data.name= filter.name
                        }
                }