首先在html页面定义好相关长度的行和列,假设table的id=data-table“”
使用jquery DataTable在js中这么写
$(function() { $('#data-table').DataTable( { order : [ [ 1, 'desc' ] ], ajax : { url : "/products", type : 'GET', dataSrc : "" }, columns : [ { data : "id" }, { data : "id" }, { data : "title", defaultContent : "" }, { data : "sell_point", defaultContent : "" }, { data : "price", defaultContent : "" },{ data : "number", defaultContent : "" },{ data : "image", defaultContent : "" },{ data : "cid", defaultContent : "" },{ data : "id" }], columnDefs : [{ targets : [ 0 ], orderable : false, render : function(id, type, row, meta) { return '<input id="input-' + id + '" type="checkbox" name="ids" value=' + id + '><label for="input-' + id + '"></label>'; } },{ targets: [8], render: function(data, type, row, meta) { return '<a title="编辑" href="javascript:;" rel="external nofollow" rel="external nofollow" onclick="product_edit('+ data +')" style="text-decoration:none"><i class="Hui-iconfont">