How to redraw datatable with new ajax request url

How to redraw datatable with new ajax request url

greennngreennn Posts: 13Questions: 8Answers: 0
edited July 2020 in Free community support

I have a server side datatable that gets it data from a certain ajax URL. Now, I have a certain situation where I want to filter the datatables using columns that doe snot exist. So I cannot just search for the value in a column. I have a ajax request that I fire on custom filter and I have the data that is in the format required for the server side datatable. How, do I draw the datatable using this new data ?

I tried doing :

tblData.clear().rows().add(data).draw()

but I got:

assignedData.js:129 Uncaught TypeError: tblData.clear(...).rows(...).add is not a function

I guess this method is not available for server side datatable?

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    I guess this method is not available for server side datatable?

    The API to add rows is rows.add(), notice no () after rows. Using tblData.clear().rows.add(data).draw() may work with server side to show the rows but it these rows will be removed on the next draw(), ie, search sort, etc.

    A better option might be to pass additional parameters using the -ajax.data option. See the second and third examples of how to do this.

    Kevin

This discussion has been closed.