DataTables warning: table id=dataTable - Requested unknown parameter 'ID' for row 0, column 0. For m
DataTables warning: table id=dataTable - Requested unknown parameter 'ID' for row 0, column 0. For m
Hi all
When I try to display my datatable after using datatables post I get the following error : DataTables warning: table id=dataTable - Requested unknown parameter 'ID' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
Please see my code for the datatable :
var dataTable = $('#dataTable').dataTable( {
"order": [[ 1, "asc" ]],
"aoColumnDefs" :
[
{
"bSortable": true ,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
},
{
"bSortable": true ,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
},
{
"bSortable": true ,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
},
{
"bSortable": true,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
},
{
"bSortable": true ,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
},
{
"bSortable": true ,
"mRender": function(amt, type, full) {
if (amt > 0 || amt < 0){
return '<?=$currency?>'+' '+formatNum(amt);
} else {
return "";
}
}
}
],
"Processing": true,
"ServerSide": true,
"sAjaxSource": '<?php echo site_url('accounting/ajax_age_history_filtered/')?>',
"POST": {
"url": '<?php echo site_url('accounting/ajax_age_history_filtered/')?>',
'dataType':'json',
'type' : 'POST',
'data': {
comparisondate: comparisonday,
start_date: start_date,
end_date: end_date
}
},
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 20,
"iDisplayStart ":20,
"columns": [{
"data": "ID",
"mDataProp": "id",
"mData": "ID"
}, {
"data": "Date",
"mDataProp": "age_date",
"mData": "Date"
}, {
"data": "Inv",
"mDataProp": "num_invoices",
"mData": "Inv"
}, {
"data": "120 Days",
"mDataProp": "d120",
"mData": "120 Days"
}, {
"data": "90 Days",
"mDataProp": "d90",
"mData": "90 Days"
}, {
"data": "60 Days",
"mDataProp": "d60",
"mData": "60 Days"
}, {
"data": "30 Days",
"mDataProp": "d30",
"mData": "30 Days"
}, {
"data": "Current",
"mDataProp": "current",
"mData": "Current"
}, {
"data": "Total",
"mDataProp": "total",
"mData": "Total"
}]
} );
here is my php server side code
$this->load->library("datatables");
$this->datatables->select('id,age_date,num_invoices,d120,d90,d60,d30,current,total')
->from('billing_age_analysis_summary')
->where('age_date >= ',$start_date)
->where('age_date <= ',$end_date);
echo $this->datatables->generate();
Datatable debug: http://debug.datatables.net/ituvul
Any help will be appreciated
Replies
However you JSON has:
Note the difference in the case. Javascript is case-sensitive, thus the error message. I think if you just match the cases it will work okay.
Allan
Hi Allan
I have managed to solve this by giving mData and mDataProp the same value in each column
{
"data": "ID",
"mDataProp": "id",
"mData": "id"
}, {
"data": "Date",
"mDataProp": "age_date",
"mData": "age_date"
},
etc
Both are legacy.
columns.data
is the parameter to use for modern versions of DataTables.Allan