Is it posibble to dynamically add columns settings for a datatable
Is it posibble to dynamically add columns settings for a datatable

columns: [
{ title: "ID" },
{ title: "Name" },
{ title: "Employee ID" },
{ title: "Designation" },
{ title: "Location" }
]
Can we make this dynamic so that I can dynamically bind data to the datatable
This discussion has been closed.
Answers
Don't know what you mean by "data". If you mean columns the answer is no, if you mean rows the answer is yes. Just use the search function and search for rows().add() etc.
It woked for me
colsObj should be dynamically generated using the logic
jQuery(document).ready(function() {
var dataObject =eval('[{"COLUMNS":['+colsObj+']}]');
var columns = [];
$('#example').dataTable({
"data": dataObject[0].DATA,
"columns": dataObject[0].COLUMNS
});
});
and in the columns section I used the below code
columns:dataObject[0].COLUMNS
settings