首先在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">
主站蜘蛛池模板:
高台县|
嘉禾县|
沂源县|
微山县|
上蔡县|
封开县|
陆良县|
儋州市|
富源县|
崇文区|
乌拉特中旗|
板桥市|
穆棱市|
巴塘县|
新和县|
济南市|
申扎县|
大埔县|
明星|
庄浪县|
新兴县|
南阳市|
呼伦贝尔市|
临泉县|
平安县|
普陀区|
襄垣县|
天峨县|
三都|
新余市|
色达县|
偃师市|
嘉禾县|
五大连池市|
铜陵市|
包头市|
仁怀市|
新建县|
镇雄县|
崇州市|
望谟县|