這篇文章將為大家詳細講解有關bootstrap表格導出如何設置,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
在bootstrap-table官網-》拓展模塊中有導出模塊的詳細介紹。
點擊home按鈕進入github官方文檔,會看到導出使用的插件是bootstrap-table-export.js ,而這個插件中使用的是tableExport.jquery.plugin插件。后者是一個獨立的表格導出插件。
而前者是經過bootstrap官方將后者與bootstrap表格進行了完美的整合之后的插件。所以我們只需要使用前者即可。
<script src="extensions/export/bootstrap-table-export.js"></script>
下面直接貼代碼:
//查詢
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', //表格數據請求地址
pagination:true, //是否分頁
search: false, //是否顯示查詢框
sortName: "id", //排序相關
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){ //表格數據加載成功事件
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, //是否顯示導出按鈕
buttonsAlign:"right", //按鈕位置
exportTypes:['excel'], //導出文件類型
Icons:'glyphicon-export',
exportOptions:{
ignoreColumn: [0,1], //忽略某一列的索引
fileName: '總臺帳報表', //文件名稱設置
worksheetName: 'sheet1', //表格工作區名稱
tableName: '總臺帳報表',
excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
onMsoNumberFormat: DoOnMsoNumberFormat
},
columns: [
{
checkbox:true,
title: '選擇'
},{
title: '序號',
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+"<span style='display:none;'>"+row.id+"</span>"
}
},{
field: 'project_name',
align:"center",
title: '項目'
}, {
field: 'user_name',
align:"center",
title: '姓名'
}, {
field: 'telephone',
align:"center",
title: '電話'
},{
field: 'id_card_number',
align:"center",
rowAttributes:"rowAttributes",
title: '身份證號'
},{
field: 'telephone',
align:"center",
title: '手機號'
},{
field: 'pos_r_n',
align:"center",
title: 'POS機參考號'
},{
field: 'pos_c_n',
align:"center",
title: 'POS機終端號'
},{
field: 'merchant_code',
align:"center",
title: '商戶編碼'
},{
field: 'bank_card_number',
align:"center",
title: '銀行卡號'
},{
field: 'create_time',
align:"center",
title: '領取優惠時間'
},{
field: 'group_purchase_number',
align:"center",
title: '優惠編碼'
},{
field: 'group_purchase_expenses',
align:"center",
title: '會員費用'
},{
field: 'back_pay_money',
align:"center",
title: '退款金額'
},{
field: 'refund_etime',
align:"center",
title: '退款時間'
},{
field: 'confirm_pay_money',
align:"center",
title: '認購金額'
},{
field: 'group_purchase_confirm_time',
align:"center",
title: '認購時間'
},{
field: 'room_confirm_number',
align:"center",
title: '認購房號'
},{
field: '',
align:"center",
title: '賬戶余額'
},{
field: 'invoice_status',
align:"center",
title: '發票狀態',
formatter: 'invoice_status_formatter',
events:'confirmEvents'
},{
field: 'lineson',
align:"center",
title: '數據來源',
formatter: 'lineson_status_formatter',
events:'confirmEvents'
}
]
});關于bootstrap表格導出如何設置就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。