我有一个包含 json 数据的“poin”列的成员表,例如:
{"IDR":"100", "MYR":"50", "DOLLAR":"25"}
如何使用数据表在一个单元格表中显示该 json 数据?
Name | Poin |
____________________
User 1|IDR : 100 |
|MYR : 50 |
|DOLLAR : 25 |
____________________
User 2|IDR : 50 |
|MYR : 80 |
|DOLLAR : 125|
这是控制器
public function query(Request $request)
{
$query = DB::table('members');
$result = DataTables::of($query)->make(true);
return $result;
}
这是blade.php
var oTable = $('#datatable-responsive').DataTable({
autoWidth: false,
processing: true,
serverSide: true,
responsive: true,
ajax: {
url: "{{route('members.query')}}",
method: "POST",
data: function (d) {
d.search = $('input[type="search"]').val();
}
},
columns: [
{data: "name"},
{data: "poin"},
{data: "created_at"}
]
});
谢谢