Join 2 columns in 1 column on Nested object data (arrays)
Join 2 columns in 1 column on Nested object data (arrays)
orik.ws
Posts: 5Questions: 2Answers: 0
Hello all,
I am loading table from ajax file. How can i join 3 column in 1 table column? (COLUMN1 COLUMN2 COLUMN3)
I tried write inside array, also with comma, also with render, but was unsuccessful.
$(document).ready(function() {
var table = $('#mainTable').DataTable( {
"Processing": true,
"ajax": {
"url": "ajax.php",
"dataSrc": "",
"type": "POST",
},
"deferRender": true,
"columns": [
{ "data": "Need to show here 3 columns as COLUMN1 COLUMN2 COLUMN3" },
{ "data": "COLUMN1" },
{ "data": "COLUMN2" },
{ "data": "COLUMN3"},
{ "data": "COLUMN4" },
{ "data": "COLUMN5" },
{ "data": "COLUMN6" },
{ "data": "COLUMN7" },
{ "data": "COLUMN8" },
{
"targets": -1,
"data": null,
"defaultContent": '<button type="button" class="btn btn-primary btn-xs">View<i class="glyphicon glyphicon-eye-open"></i></button>'
}
]
} );
$('#mainTable tbody').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
location.href = "mypage.php?ID="+data[0];
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @orik.ws ,
You would use
columns.render
to do that, see example here.Cheers,
Colin