這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)如何實(shí)現(xiàn)bootstrap-table表格導(dǎo)出,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站制作、網(wǎng)站建設(shè)、桂平網(wǎng)絡(luò)推廣、微信小程序開發(fā)、桂平網(wǎng)絡(luò)營銷、桂平企業(yè)策劃、桂平品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供桂平建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com
文檔參數(shù)說明:
Table Export
Use Plugin: tableExport.jquery.plugin
Usage
Options
showExport //是否顯示到處按鈕
type: Boolean
description: set true to show export button.
default: false
exportDataType //導(dǎo)出表格方式(默認(rèn)basic:只導(dǎo)出當(dāng)前頁的表格數(shù)據(jù);all:導(dǎo)出所有數(shù)據(jù);selected:導(dǎo)出選中的數(shù)據(jù))
type: String
description: export data type, support: 'basic', 'all', 'selected'.
default: basic
exportTypes //導(dǎo)出文件類型 ,支持多種類型文件導(dǎo)出
type: Array
description: export types, support types: 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'xlsx', 'pdf'.
default: ['json', 'xml', 'csv', 'txt', 'sql', 'excel']
exportOptions //導(dǎo)出的表格參數(shù)設(shè)置,這里參照tableExport.jquery.plugin插件中的參數(shù)進(jìn)行設(shè)置,點(diǎn)擊官網(wǎng)文檔中的option藍(lán)色字體就可跳轉(zhuǎn)到該插件的說明文檔處,網(wǎng)址:https://github.com/hhurz/tableExport.jquery.plugin#options。
type: Object
description: export options of tableExport.jquery.plugin
default: {}
Icons //導(dǎo)出按鈕圖標(biāo)設(shè)置
export: 'glyphicon-export icon-share'
下面直接貼代碼:
//查詢
function refresh(){
$("#datatable").bootstrapTable('refresh',{url:'__MODULE__/Statistics/listData'});
}
//查詢條件
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, //是否分頁
search: false, //是否顯示查詢框
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){ //表格翻頁事件
$("#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)出文件類型
Icons:'glyphicon-export',
exportOptions:{
ignoreColumn: [0,1], //忽略某一列的索引
fileName: '總臺(tái)帳報(bào)表', //文件名稱設(shè)置
worksheetName: 'sheet1', //表格工作區(qū)名稱
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: '電話'
},{
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: '商戶編碼'
},{
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)購金額'
},{
field: 'group_purchase_confirm_time',
align:"center",
title: '認(rèn)購時(shí)間'
},{
field: 'room_confirm_number',
align:"center",
title: '認(rèn)購房號(hào)'
},{
field: '',
align:"center",
title: '賬戶余額'
},{
field: 'invoice_status',
align:"center",
title: '發(fā)票狀態(tài)',
formatter: 'invoice_status_formatter',
events:'confirmEvents'
},{
field: 'lineson',
align:"center",
title: '數(shù)據(jù)來源',
formatter: 'lineson_status_formatter',
events:'confirmEvents'
}
]
});上述就是小編為大家分享的如何實(shí)現(xiàn)bootstrap-table表格導(dǎo)出了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。