I am using datatables and would like to over-ride the contents of a cell depending on the value it contains. I am using '1' to flag true in the underlying database and '0' for false. I am attempting to use the Columndefs render function to do this.
Here is my code..
xample_table = $('#treatment_list').DataTable(
{
select: true,
destroy: true,
"order": [ 0, 'desc' ],
data:json,
columns : [
{'data':'treatment_name'},
{'data':'description'},
{'data':'measured_in'},
{'data':'exclusive'}
],
"columnDefs": [
{
"targets":3,
"data" : "exclusive",
"render": function ( data, type, row ) {
if (type === 'display'){
if (row.exclusive == '0')
{
return 'No';
}
else
return 'Yes';
}
}
}
]
}
);
The problem is I get an erro message from datatables that reads..
DataTables warning: table id=treatment_list - Requested unknown parameter 'exclusive' for row 0, column 3....
Apart from the error message, it is in fact working.
console.print( data );
andconsole.print( row );
to the body of your column render function. If that does not help, then you can edit your question to show us the JSON. (Use F12 to open the browser's console, if you are not familiar with it.) – andrewJames