You may employ columns.render option for that purpose. It accepts your cell data, cell data type, entire row data source and row number/column number as arguments.
So, for your target column you may make up combined field that will contain as many fields as needed referred by corresponding property name.
For instance, if the source data for each row of your table is an object, like:
{id: 'someid', name: 'somename', phone: 'somephone', mail: 'somemail'}
And you would like to merge phone and mail into combined column contacts, you may simply do:
$('#example').DataTable({
...
columns: [
{title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
]
});
Complete demo of this concept you may find below:
//data sample that mimic response from your back-end PHP script
const srcData = [
{id: 1, name: 'Steve Rogers', phone: '+1987270123512', mail: '[email protected]'},
{id: 2, name: 'Tony Stark', phone: '+1987987235143', mail: '[email protected]'},
{id: 3, name: 'Peter Parker', phone: '+1698701245121', mail: '[email protected]'}
];
//datatables initialization
const dataTable = $('#example').DataTable({
dom: 't',
data: srcData,
columns: [
{title: 'id', data: 'id'},
{title: 'name', data: 'name'},
{title: 'contacts', data: null, render: (data, type, row, meta) => `phone: ${row.phone}, e-mail: ${row.mail}`}
]
});
<!doctype html>
<html>
<head>
<script type="application/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="application/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
</head>
<body>
<table id="example"></table>
</body>
</html>