【发布时间】:2017-12-16 21:27:57
【问题描述】:
我的网站包含内置 ajax 的基本 CRUD 操作,我的问题是,如何实现数据表?顺便说一句,我已经部署了 yajra 数据表
js文件
$(function () {
$('#example').DataTable({
});});
function manageRow(data) {
var rows = '';
$.each( data, function( key, value ) {
rows = rows + '<tr>';
rows = rows + '<td>'+value.title+'</td>';
rows = rows + '<td>'+value.description+'</td>';
rows = rows + '<td data-id="'+value.id+'">';
rows = rows + '<button data-toggle="modal" data-target="#edit-item" class="btn btn-primary edit-item">Edit</button> ';
rows = rows + '<button class="btn btn-danger remove-item">Delete</button>';
rows = rows + '</td>';
rows = rows + '</tr>';
});
$("tbody").html(rows);}
查看
<table id="example" class="display" cellspacing="1" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
</tr>
</thead>
<tbody>
</tbody></table>
【问题讨论】:
标签: javascript php ajax datatable laravel-5.4