Ich verwende jQuery-Datatables, um Daten über Ajax und SQL auszugeben. Ich kann die Daten gut ausgeben. Allerdings möchte ich zwei der Rückgabeobjekte in einer Spalte kombinieren, da es sich um dieselbe Sache handelt.Anzeigen von zwei Objekten in einer AJAX-Datatable-Spalte
$('#todayApt').on('show.bs.modal', function (event){
$('#todayAptList').DataTable({
"ajax": {
"url": '{{ url('panel/appointment/ajax/schedule/week/lookup') }}',
dataSrc: ''
},
"columns": [
{ "data": "date" },
{ "data": "office" },
{ "data": "block" },
{ "data": "last_name" },
{ "data": "street_1" },
{ "data": "zip_code" },
{ "data": "phone_1" },
{ "data": "service_detail" }
]
});
});
Mein Ziel ist wie folgt:
[
{
"street_1":"1234 Main St",
"phone_2":"(555) 555-5555",
"street_2":null,
"date":"2016-10-19",
"users_info_id":19,
"last_name":"Doe",
"phone_1":"(555) 555-5555",
"zip_code":90210,
"status":"scheduled",
"office":"location",
"block":"9-12",
"special_detail":null,
"mp_detail":null,
"service_detail":"Service Details"
}
]
So service_detail, mp_detail und special_detail ich gerade möchte in einer einzigen Spalte zu der Bezeichnung 'Details'. Ich kann herausfinden, wie einzelne Spalten zu tun, aber kann nicht herausfinden, wie man in nur einer Spalte
Beispiel der erwarteten Ergebnisse mehr als eine tun:
<table id="todayAptList" class="table table-striped table-bordered dt-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th>Date</th>
<th>Office</th>
<th>Block</th>
<th>Last Name</th>
<th>Address</th>
<th>Zip Code</th>
<th>Phone</th>
<th>Services</th>
</thead>
<tbody>
<tr role="row" class="odd">
<td class="sorting_1" tabindex="0">2016-10-18</td>
<td>Location</td>
<td>3-5</td>
<td>Doe</td>
<td>1234 Main St</td>
<td>90210</td>
<td>(555) 555-5555</td>
<td>SPECIAL, MP AND SERVICE DETAILS HERE IN ONE</td>
</tr>
</tbody>
Ist das Rückkehrergebnis ein JSON-Objekt? – Anson
Ja ist es. Ich bearbeite meine Antwort, um die richtige JSON-Antwort anzuzeigen, die ein Dump von meinem SQL-Objekt war. – Lynx
Können Sie das Ergebnis liefern, das Sie erwarten? – Anson