Loading Ajax sourced data in the form of objects
Loading Ajax sourced data in the form of objects
Hi, I'm new to datatables and would like to get directions on how to Initialize the datatable columns dynamically (based on the Ajax sourced data in the form of objects). I.e Instead of hardcoding "Name", I would like to get the column name/index generated automatically. Note its a client side search/filtering used.
Many thanks !
function LoadData() {
// Init datatable
var data_table = $('#myTable').DataTable({
"columns": [
{ "data": "Name" }
]
});
// perform ajax call and load data
data_table.ajax.url("/MyAjaxFunction").load();
}
Answers
Hi this is actually in the FAQs
Here's a link for you https://datatables.net/faqs/index#ajax-columns
Thanks
Tom