how to get the dynamic column header and result from ajax call in jquery datatable
how to get the dynamic column header and result from ajax call in jquery datatable
bhagya
Posts: 6Questions: 3Answers: 0
I want to display the dynamic column header along with the results in datatable.In aaData and aoColumns attributes has to get result data and columns name from ajax call, Please suggest me how to do this or give me some alternate solution to get the dynamic data and column header from ajax call, Here is my code.:
var $table=$('#MSRRes').dataTable( {
"bFilter": false,
"bDestroy": true,
"bDeferRender": false,
"bJQueryUI": true,
"oTableTools": {
"sSwfPath": "swf/copy_cvs_xls_pdf.swf",
},
"sDom": 'TC<"clear">l<"toolbar">frtip',
"ajax" :{
url: 'getResult.php',
type: "POST",
data: {
formData:postData,
}
},
"aaData": results.DATA ,
"aoColumns": [ column_names ]
});
Here is my ajax call to get the result data and column names to be display:
$result=$afscpMsrMod->getAdvanceSearchResults();
$colArr=array("MSR","NAME","ACCOUNT NUM","MCN","COUNT");
$colJson= json_encode($colArr);
$newarray = array(
"draw" => 1,
"recordsTotal" => sizeof($result),
"recordsFiltered" => sizeof($result),
"data" => $result,
"COLUMNS" => $colJson
);
echo json_encode($newarray);
This discussion has been closed.