Undefined error when combining data from column 4 with that of 3
Undefined error when combining data from column 4 with that of 3
stichcomber
Posts: 26Questions: 7Answers: 3
I would like to combine column 4 data with column 3. I get "undefined" by the data in column 3. I have tried columnDefs and columns and both return the same. Also, I cannot find an explanation of function ( data, type, row ) and function ( data, type, full, meta ) . Any help much appreciated.
$(document).ready(function () {
$('#myDataTable').dataTable( {
"ajax": "json_get_countries",
// country column does not work as expected. It shows "undefined" and a hyperlink
// connected to the word underdefined
"columnDefs": [
// COUNTY_ID
{
"targets": 0,
"data": "country_id",
"searchable" : false
},
// COUNTRY
{
"targets": 1,
"data": "country",
"render": function ( data, type, full, meta ) {
return '<a href="'+data+'">'+data+'</a>';
}
},
//COUNTRY_ENABLED
{
"targets": 2,
"data": "country_enabled",
"render": function ( data, type, row ) {
return data +' ('+ row[3]+')';
}
},
//numberOfDestinations
{
"targets": 3,
"data": "numberOfDestinations" ,
"visible": false
}
]
} );
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I have an associative array and, therefore, the proper way to access the data is with row['numberOfDestinations']
Ref: http://stackoverflow.com/questions/19777075/datatables-merge-columns-together
Hi,
Thanks for posting back - good to hear you've got this sorted out now!
Regards,
Allan