先看插件说明,再看options的设置即可.
排序主要看:
sorter:numberSort
导出文件格式化主要看:
showExport:true,
exportOptions:{
fileName:"例子后端常规监控",
worksheetName:"例子后端常规监控",
onCellData:function(cell, row, col, data){
if(row == 0){
return data;
}else{
return data.replace(/\([^\)]*\)/g,"");
}
}
},
https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/export
https://github.com/hhurz/tableExport.jquery.plugin#options
//数据排序算法
function numberSort(a,b){
a = a.replace(/\([^\)]*\)/g,"");//正则 去掉小括号及里边的内容
b = b.replace(/\([^\)]*\)/g,"");
var numa = parseFloat(a);
var numb = parseFloat(b);
return a - b;
}
//日期排序算法
sorter:function(a, b){
var d1 = new Date(a.replace(/\-/g, "\/"));
var d2 = new Date(b.replace(/\-/g, "\/"));
if(a != "" && b != ""){
return d1 - d2;
}
}
//bootstrap table初始化函数
$('#table').bootstrapTable({
showToggle:false,
showPaginationSwitch:true, //
showColumns:true, //可选列按钮
iconsPrefix:"glyphicon", //图标样式
iconSize:"sm", //图标大小
striped:true,
classes:"table table-striped table-bordered table-hover",
pagination:true, //底部分页
sidePagination:"client",
showExport:true,
exportOptions:{
fileName:"例子后端常规监控",
worksheetName:"例子后端常规监控",
onCellData:function(cell, row, col, data){
if(row == 0){
return data;
}else{
return data.replace(/\([^\)]*\)/g,"");
}
}
},
search:true,
undefinedText:"无",
pageSize: 20, //每页的记录行数(*)
pageList: [20, 50, 100, 150], //可供选择的每页的行数(*)
//sortable: true, //是否启用排序
//sortName:"stat_dt",
//sortOrder:"desc",
columns:[
{
field:"stat_dt",
title:"统计日期",
sortable:true,
sorter:function(a, b){
var d1 = new Date(a.replace(/\-/g, "\/"));
var d2 = new Date(b.replace(/\-/g, "\/"));
if(a != "" && b != ""){
return d1 - d2;
}
}
},
{
field:"platform",
title:"平台",
sortable:true
},
{
field:"app_name",
sortable:true,
title:"APP名称",
formatter:function(value,row,index){
if(value == "other"){
return "无";
}
return value;
}
},
{
field:"order_num",
sortable:true,
title:"例子订单量",
sorter:numberSort
},
......