我为 Laravel 5.4 使用 DataTables 和 yajra / laravel-datatables-oracle 包。我希望在 screen_name 列中显示 screen_name 。 screen_name 位于JSON对象中( JSON结果)。
$(document).ready(function() {
$('#logs-table').DataTable({
processing: true,
serverSide: true,
stateSave: true,
ajax: 'api/ajax-file',
columns: [
{ data: 'credentials.screen_name', name: 'credentials.screen_name' }
],
aoColumns: [
{
aTargets: [0],
mData: 'credentials.screen_name',
mRender: function (data, type, full) {
return '<strong>' + data + '</strong>';
}
}
]
});
});
<table class="table table-hover table-striped" id="logs-table">
<thead>
<tr>
<th>User</th>
</tr>
</thead>
</table>
{
"draw":0,
"recordsTotal":208,
"recordsFiltered":208,
"data": [{
"_id":"5960e2f59f9d5158f7129d82",
"credentials":{
"id":"1",
"id_str":"1",
"name":"User 1",
"screen_name":"user1"
},
...
}]
}
public function ajax(Request $request)
{
$users = User::all();
return Datatables::of($users)->make(true);
}