Passing JSON string to DataTable
Passing JSON string to DataTable
anjibman
Posts: 115Questions: 10Answers: 0
Hi All,
I am trying to pass a JSON string to a DataTable but not sure which API I have to use. I have initialized the DataTable on document ready but no data in it for now. We get data from aseperate AJAX call so I have JSON string on succcess call back funxtion of AJAX call. Now I have to load/send this JSON string to the table. How can I do this?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
http://datatables.net/examples/data_sources/ajax.html
Hope following code snippet help to understand my question.
Use
rows.add()
to add new data to the table.Allan
I am using v1.10.2 but I am getting
Second top FAQ:
Q. I get an error message stating that an API method is not available
A. Very likely you are using a jQuery object rather than a DataTables API instance. The form
$().dataTable()
will return a jQuery object, while$().DataTable()
returns a DataTables API instance. Please see the API documentation for further information.Allan
I am able to load the content but I have another question here. My 5th columns is an address so it should combine different field from the JSON string (e.g. addressLine1, addressLine2, city, state, and zipcode). How can I load and format the column so it have following format
My code look like this
Use
columns.render
.Allan
Write yourself a "render" function.
https://datatables.net/reference/option/columns.render