Loading Ajax sourced data in the form of objects

Loading Ajax sourced data in the form of objects

tgvenutgvenu Posts: 1Questions: 1Answers: 0

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

This discussion has been closed.