Can you please help on the problem with columns loading dynamically?
Can you please help on the problem with columns loading dynamically?
Hello
I am suffering from the same problem where we can get column names dynamically.
Ref: http://www.datatables.net/forums/discussion/6260/dynamic-column-names
I have tried your answer but I am not getting the data. I am also using the Coldfusion and SerielizedJSON. my Code :
function callStatusSearch() {
$.ajax({
type: "post",
url: "CallStatus-flash.cfc",
data: {
indexrow:"all",
username:"SPAMN",
customercode:"SPAMN",
stat:$("#st").val(),
firstdate:$("#sd1").val(),
lastdate:$("#ed1").val(),
subcustomer:"SPAMN",
custidfilter:"0",
calltypefilter:"0",
queuefilter:"0",
method:"statusrepJSON",
},
dataType: "json",
success: function(res){
// --------------------------------------Your Code----------------------------//
$(document).ready(function() {
var columns = [];
jQuery.each(res.COLUMNS, function(i, value){
var obj = { sTitle: value };
columns.push(obj);
});
alert(res.COLUMNS);
$('#example').dataTable( {
"data":res.DATA,
"aoColumnDefs":res.COLUMNS,
"bDestroy": true
} );
//------------------------------------------------------------------------------//
} );
switch(res)
{
}
},
error: function(err){
//alert(err.statusText);
}
});
var tbl = document.getElementById(example);
if(tbl) tbl.parentNode.removeChild(tbl);
}
//Table in HTML Format
Cust_ID | Call_ID | Site_ID | Cust_PO | City | State | Due_Date | Conf_Time | Tent_Date | Arr_Date | Arr_Time | Call_Type | Status |
---|
Thanks,
Sai