【发布时间】:2015-11-23 22:41:24
【问题描述】:
我想使用服务器端处理模式将我的记录数据显示到由 jQuery DataTables 插件增强的表中。我关注了文档Datatables Server side,但在我的表格中我无法显示记录数据。
这是我的 Ajax 响应:
{
"draw": 0,
"recordsTotal": 4,
"recordsFiltered": 4,
"data": [
[
27,
"Brokoli Segar",
"25000"
],
[
28,
"Tomat Super",
"2000"
],
[
29,
"Oreo Roll",
"9400"
],
[
30,
"Close Up Toothpaste Fire Freeze",
"7000"
]
],
"queries": [
{
"query": "select count(*) as aggregate from (select '1' as row_count from `product` where `product`.`deleted_at` is null) count_row_table",
"bindings": [],
"time": 0.79
},
{
"query": "select `id`, `name`, `price` from `product` where `product`.`deleted_at` is null",
"bindings": [],
"time": 0.68
}
],
"input": []
}
我的 HTML 表格:
<table class="table table-bordered" id="tabelStokBarang">
<thead>
<tr>
<th>ID</th>
<th>Nama Barang</th>
<th>Harga Barang</th>
</tr>
</thead>
</table>
我的 JavaScript:
$('#tabelStokBarang').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('admin.product.stock.getAll') !!}',
columns: [
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'price', name: 'price' }
]
});
我在表格中的结果仍然是“无可用数据”。我不知道我错过了什么。
【问题讨论】:
-
您好,您是如何解决这个问题的。我也遇到了同样的问题。
标签: javascript datatables laravel-5.1