How to add columns in datatable dynamically?
How to add columns in datatable dynamically?
step1020304050
Posts: 3Questions: 3Answers: 0
This is my current initialization. But, I don't know how to change the columns dynamically? Table Header and results will vary because of the filter I have in my original source codes.
Current Table Header:
Date | Quantity | Color
Ideally, After Ajax Call:
Date | Quantity | Color | Price (2015) | Price (2014) | Price (2012) ....
tbl.DataTable({
"ajax": {
"type": "POST",
"beforeSend": function(xhr){
loading_modal.modal('show');
},
"url": "/reports/get_transaction",
"data": function ( d ) {
d.params = frm.serializeArray();
}
},
"initComplete": function(settings, json) {
if(json.data == "session_timeout"){
redirect();
}
},
"columns": [
{ "data": "date" },
{ "data": "quantity" },
{ "data": "color" }
]
});
This discussion has been closed.