日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dataTables去掉搜索框,每页多少条框体,解决Cannot reinitialise DataTable问题,以及数据格式ajax等问题...

發(fā)布時間:2023/12/18 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dataTables去掉搜索框,每页多少条框体,解决Cannot reinitialise DataTable问题,以及数据格式ajax等问题... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1。關于datatables配置

function dosearch(){

$('#example').DataTable({
"searching": false, //去掉搜索框
"bLengthChange":false,//去掉每頁多少條框體
"language": { //如果本來就可以中文的,這個配置其實是不需要的,
? "info": "", // 表格左下角顯示的文字 ? ?,這句也可以,用別外方式,"info": false,
? "paginate": {
? "previous": "上一頁",
? "next": "下一頁" }

},

"info": false, //去掉info,

"bPaginate":false,//去掉分頁,
"destroy":true, //Cannot reinitialise DataTable,解決重新加載表格內容問題 ,重新加載數(shù)據(jù)時,它就不會報錯了,
"data": getdd(),// 后臺傳過來的json是字符串轉成對象
"columns": [

{ ? //添加一個checkbox的列,就是說每行都有個checkbox,主要用于行多選操作,如批量刪除

? ??"sClass": "text-center",
? ??"data": "A0",
? ??"render": function (data, type, full, meta) {
? ??? ??return '<input type="checkbox" class="checkchild" name="A0" value="' + data + '" />';
? ??},
"bSortable": false

},

{ "data": "A1" },
{ "data": "A2" },
{ "data": "A3" },
{

"data": "A0",
"render": function (data, type, full, meta) {
return '<a style="text-decoration: none" class="ml-5" οnclick="edit(\'編輯\',\'' + data + '\',\'pageAdd.aspx\')" href="javascript:;" title="編輯"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration: none" class="ml-5" οnclick="del(this,\'' + data + '\')" href="javascript:;" title="刪除"><i class="Hui-iconfont">&#xe6e2;</i></a>';
}

},

],

//"sPaginationType": "full_numbers", //這個是顯示首頁,末頁,默認顯示的上頁下頁,及中間數(shù)字的頁數(shù),//不顯示分頁時這個不用了,
});

?

}

dosearch();//加載執(zhí)行,以及,可以在一個測試按鈕的click,執(zhí)行,這時它的數(shù)據(jù)會由dd變成dd2,如此,做ajax的數(shù)據(jù)格式可以大致確定了,

//另外,這個json給的是一個數(shù)組,沒有返回記錄數(shù)等信息,如需要,可以自己改變json格式來做,

?

下面是一個測試數(shù)據(jù)來源,///。交互數(shù)據(jù)格式:


datadel = function () {
//alert($("input[name='A0']:checked").length);
}
var dd = [
{ "A0": "1", "A1": "fslfjsdf", "A2": 12312, "A3": true },
{ "A0": "2", "A1": "fslfjsdf", "A2": 12312, "A3": true }
];
var dd2 = [
{ "A0": "1", "A1": "fslfjsdf1", "A2": 12312, "A3": true },
{ "A0": "2", "A1": "fslfjsdf2", "A2": 12313, "A3": false },
{ "A0": "3", "A1": "fslfjsdf3", "A2": 12314, "A3": true }
];
var a = 0;
function getdd() {
a = a + 1;
if (a == 1) return dd;
return dd2;
}

?

?

2。html寫法

?


<table class="table table-border table-bordered table-bg table-hover table-sort">
<thead>
<tr class="text-c">
<th width="40">
<input name="" type="checkbox" value=""></th>
<th width="100">標題</th>
<th width="100">主題分類</th>
<th width="100">圖片</th>
<th width="100">操作</th>
</tr>
</thead>
<!--
這里也可以有 <tfoot>...</tfoot>包含和表頭類似的列,不用也可以,
<tbody>...</tbody> 由上面的js執(zhí)行后生成,

分頁,目前datatables,個人覺得不太好用,但是樣式可以參考,具體不細說了,
-->

</table>

?

?

?

?

?

參考 http://blog.csdn.net/bug12138/article/details/53127640

轉載于:https://www.cnblogs.com/ijunxiong/articles/6848100.html

總結

以上是生活随笔為你收集整理的dataTables去掉搜索框,每页多少条框体,解决Cannot reinitialise DataTable问题,以及数据格式ajax等问题...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。