淺析Bootstrap表格的使用
Bootstrap - 簡(jiǎn)潔、直觀、強(qiáng)悍、移動(dòng)設(shè)備優(yōu)先的前端開發(fā)框架,讓web開發(fā)更迅速、簡(jiǎn)單。下面給大家介紹Bootstrap表格的使用,一起學(xué)習(xí)吧。
先定義前端table
<table class="table table-striped table-bordered table-hover" id="expandabledatatable"></table>
然后是JS
/*
* 初始化表格
*/
var oTable = $('#expandabledatatable').dataTable({
"sDom": "Tflt<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>",
"aoColumnDefs": [
{
"bSortable": false, "aTargets": [0],
"render": function (data, type, full) {
return '<i class="fa fa-plus-square-o row-details"></i>';
}
},
{ "aTargets": [1], "data": "TaskName", "title": "任務(wù)名稱" },
{ "aTargets": [2], "data": "CronExpression", "title": "表達(dá)式" },
{ "aTargets": [3], "data": "Remark", "title": "說(shuō)明" },
{
"bSortable": false, "aTargets": [4], "title": "運(yùn)行狀態(tài)",
"render": function (data, type, full) {
if (full["Enabled"]==true){
return '<button type="button" class="btn btn-success btn-sm">運(yùn)行</button>';
}
else {
return '<button type="button" class="btn btn-warning btn-sm">停止</button>';
}
}
},
{
"bSortable": false, "aTargets": [5],
"render": function (data, type, full) {
return '<a href="#" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 編輯</a> <a href="#" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 刪除</a>';
}
}
],
"bServerSide": true,
"sAjaxSource": "/Task/GetAllTask",
"aaSorting": [[1, 'asc']],
"aLengthMenu": [
[5, 15, 20, -1],
[5, 15, 20, "All"]
],
"iDisplayLength": 5,
"searching": false,
"bLengthChange": false,
"language": {
"sProcessing": "正在加載數(shù)據(jù)...",
"sInfoEmpty": "記錄數(shù)為0",
"sInfoFiltered": " 從 _MAX_ 條過(guò)濾",
"sZeroRecords": "沒有您要搜索的內(nèi)容",
"search": "",
"sLengthMenu": "_MENU_",
"sInfo": "從 _START_ 到 _END_ /共 _TOTAL_ 條數(shù)據(jù)",
"oPaginate": {
"sPrevious": "上一頁(yè)",
"sNext": "下一頁(yè)",
}
},
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"type": 'post',
"url": sSource,
"dataType": "json",
"data": {
aoData: JSON.stringify(aoData)
},
"success": function (resp) {
fnCallback(resp);
}
});
}
});
該表格的數(shù)據(jù)是從服務(wù)器端取得,所以必須配置下面這些屬性,否則無(wú)法從服務(wù)器端獲得數(shù)據(jù)
"bServerSide": true,
"sAjaxSource": "/Task/GetAllTask",
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"type": 'post',
"url": sSource,
"dataType": "json",
"data": {
aoData: JSON.stringify(aoData)
},
"success": function (resp) {
fnCallback(resp);
}
});
}
以上所述是小編給大家介紹的Bootstrap表格的使用的相關(guān)知識(shí),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
微信小程序?qū)崿F(xiàn)自動(dòng)播放視頻模仿gif動(dòng)圖效果實(shí)例
這篇文章主要給大家介紹了關(guān)于微信小程序?qū)崿F(xiàn)自動(dòng)播放視頻模仿gif動(dòng)圖效果的相關(guān)資料,通過(guò)本文介紹的方法可以實(shí)現(xiàn)自動(dòng)播放視頻,視頻無(wú)控制條無(wú)聲音且自動(dòng)循環(huán)播放,需要的朋友可以參考下2021-07-07
檢查輸入的是否是數(shù)字使用keyCode配合onkeypress事件
檢查輸入的是否是數(shù)字在本文使用keyCode配合onkeypress事件來(lái)實(shí)現(xiàn),具體示例如下2014-01-01
JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航
這篇文章主要介紹了JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07
javascript中的previousSibling和nextSibling的正確用法
這篇文章主要介紹了javascript中的previousSibling和nextSibling的正確用法的相關(guān)資料,需要的朋友可以參考下2015-09-09

