首先在html頁面定義好相關(guān)長度的行和列,假設(shè)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 +')" ><i class="Hui-iconfont"></i></a><a title="刪除" href="javascript:;" rel="external nofollow" rel="external nofollow" onclick="product_del(' + data +')" class="ml-5" ><i class="Hui-iconfont"></i></a>'
}
}]
});
});
本文名稱:使用jqueryDataTable和ajax向頁面顯示數(shù)據(jù)列表的方法-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://chinadenli.net/article14/hpsge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、靜態(tài)網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站、ChatGPT、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容