十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶(hù) + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專(zhuān)業(yè)推廣+無(wú)憂(yōu)售后,網(wǎng)站問(wèn)題一站解決
這篇文章將為大家詳細(xì)講解有關(guān)bootstrap表格導(dǎo)出如何設(shè)置,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

在bootstrap-table官網(wǎng)-》拓展模塊中有導(dǎo)出模塊的詳細(xì)介紹。
點(diǎn)擊home按鈕進(jìn)入github官方文檔,會(huì)看到導(dǎo)出使用的插件是bootstrap-table-export.js ,而這個(gè)插件中使用的是tableExport.jquery.plugin插件。后者是一個(gè)獨(dú)立的表格導(dǎo)出插件。
而前者是經(jīng)過(guò)bootstrap官方將后者與bootstrap表格進(jìn)行了完美的整合之后的插件。所以我們只需要使用前者即可。
下面直接貼代碼:
//查詢(xún)
function refresh(){
$("#datatable").bootstrapTable('refresh',{url:'__MODULE__/Statistics/listData'});
}
//查詢(xún)條件
function queryParams(params){
params['project_id'] = $("select[name=project_id]").find("option:selected").val();
params['time_field'] = $("select[name=time_field]").find("option:selected").val();
params['start_time'] = $("input[name=start_time]").val();
params['end_time'] = $("input[name=end_time]").val();
params['user_name'] = $("input[name=user_name]").val();
params['telephone'] = $("input[name=telephone]").val();
params['room_confirm_number'] = $("input[name=room_confirm_number]").val();
params['lineson'] = $("select[name=lineson]").val();
params['invoice'] = $("select[name=invoice]").val();
return params;
}
function DoOnMsoNumberFormat(cell, row, col) {
var result = "";
if (row > 0 && col == 0)
result = "\\@";
return result;
}
var rowCount = 0;
$("#datatable").bootstrapTable({
height:"500",
url: '__MODULE__/Statistics/listData', //表格數(shù)據(jù)請(qǐng)求地址
pagination:true, //是否分頁(yè)
search: false, //是否顯示查詢(xún)框
sortName: "id", //排序相關(guān)
sortOrder: "desc",
queryParams:'queryParams',
method:"post",
sortable:true,
dataType:'json',
toolbar: "#exampleTableEventsToolbar",
icons: {refresh: "glyphicon-repeat", toggle: "glyphicon-list-alt", columns: "glyphicon-list"},
pageList:[10, 25, 50, 100],
clickToSelect:true,
exportDataType:'all',
onLoadSuccess:function(data){ //表格數(shù)據(jù)加載成功事件
rowCount = data.length-1;
$("#datatable").bootstrapTable('hideRow', {index:rowCount});
$("#datatable td").attr("data-tableexport-msonumberformat","\@");
$("#datatable tr").attr("data-tableexport-display","always");
},
onPageChange:function(number,size){ //表格翻頁(yè)事件
$("#datatable").bootstrapTable('hideRow', {index:rowCount});
$("#datatable td").attr("data-tableexport-msonumberformat","\@");
$("#datatable tr").attr("data-tableexport-display","always");
},
showExport: true, //是否顯示導(dǎo)出按鈕
buttonsAlign:"right", //按鈕位置
exportTypes:['excel'], //導(dǎo)出文件類(lèi)型
Icons:'glyphicon-export',
exportOptions:{
ignoreColumn: [0,1], //忽略某一列的索引
fileName: '總臺(tái)帳報(bào)表', //文件名稱(chēng)設(shè)置
worksheetName: 'sheet1', //表格工作區(qū)名稱(chēng)
tableName: '總臺(tái)帳報(bào)表',
excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
onMsoNumberFormat: DoOnMsoNumberFormat
},
columns: [
{
checkbox:true,
title: '選擇'
},{
title: '序號(hào)',
formatter: function (value, row, index) {
$(".group_sum").html(row['group_sum']);
$(".group_money_sum").html(row['group_money_sum']+"元");
$(".confirm_sum").html(row['confirm_sum']);
$(".confirm_money_sum").html(row['confirm_money_sum']+"元");
$(".refund_sum").html(row['refund_sum']);
$(".refund_money_sum").html(row['group_back_sum']+"元");
$(".residue_money_sum").html(row['residue_sum']+"元");
var a = index+1; return a+""
}
},{
field: 'project_name',
align:"center",
title: '項(xiàng)目'
}, {
field: 'user_name',
align:"center",
title: '姓名'
}, {
field: 'telephone',
align:"center",
title: '電話(huà)'
},{
field: 'id_card_number',
align:"center",
rowAttributes:"rowAttributes",
title: '身份證號(hào)'
},{
field: 'telephone',
align:"center",
title: '手機(jī)號(hào)'
},{
field: 'pos_r_n',
align:"center",
title: 'POS機(jī)參考號(hào)'
},{
field: 'pos_c_n',
align:"center",
title: 'POS機(jī)終端號(hào)'
},{
field: 'merchant_code',
align:"center",
title: '商戶(hù)編碼'
},{
field: 'bank_card_number',
align:"center",
title: '銀行卡號(hào)'
},{
field: 'create_time',
align:"center",
title: '領(lǐng)取優(yōu)惠時(shí)間'
},{
field: 'group_purchase_number',
align:"center",
title: '優(yōu)惠編碼'
},{
field: 'group_purchase_expenses',
align:"center",
title: '會(huì)員費(fèi)用'
},{
field: 'back_pay_money',
align:"center",
title: '退款金額'
},{
field: 'refund_etime',
align:"center",
title: '退款時(shí)間'
},{
field: 'confirm_pay_money',
align:"center",
title: '認(rèn)購(gòu)金額'
},{
field: 'group_purchase_confirm_time',
align:"center",
title: '認(rèn)購(gòu)時(shí)間'
},{
field: 'room_confirm_number',
align:"center",
title: '認(rèn)購(gòu)房號(hào)'
},{
field: '',
align:"center",
title: '賬戶(hù)余額'
},{
field: 'invoice_status',
align:"center",
title: '發(fā)票狀態(tài)',
formatter: 'invoice_status_formatter',
events:'confirmEvents'
},{
field: 'lineson',
align:"center",
title: '數(shù)據(jù)來(lái)源',
formatter: 'lineson_status_formatter',
events:'confirmEvents'
}
]
});關(guān)于bootstrap表格導(dǎo)出如何設(shè)置就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。