# 问题描述:
**表格打印碰到对象的时候出现object问题,我在js里面是用formatter格式化显示的(表格里面我显示的是对象的属性),但是打印就会出现object**
## 打印之前的界面:
**圈起来那两个都是对象,我只取了其中一个属性**
## 点击打印之后:
这个怎么解决?
## 我的table标签:
` <table id="table" class="table" data-click-to-select="true"
data-show-print="true">
</table>`
打印按钮里做了什么?
把你打印的代码贴出来,猜一下,估计是层次的问题
下面有我的js代码,这里面没有打印的代码,你可以看下油井编号和报警级别编号两个字段是被我用formatter格式化过的,打印的就<table>标签里面的一句
data-show-print="true"
前端页面是这样的
js代码如下:
$('#table').bootstrapTable({
url:'/opms/oilDaily/listByMonthReport',
toolbar:'#toolbar',
dataType:'json', //服务器返回的数据类型
method:'post', //请求方式
contentType: "application/x-www-form-urlencoded;charset=UTF-8",//发送到服务器的数据编码类型
pagination:true, //是否显示分页
pageSize:8, //设置每页的记录行数
pageList: [8,16,32,64,256,'All'], //可供选择的每页的行数
pageNumber:1, //设置首页页码
singleSelect:false, //设置是否单选
checkboxHeader: true,
sortable:true, //是否启用排序
sortOrder:'asc', //排序方式
showRefresh:true, //是否显示刷新按钮
showToggle:true, //是否显示详细视图和列表视图的切换按钮
showColumns:true, //选择要显示的列
striped: true, //是否显示行间隔色
clickToSelect:true, //是否启用点击选中行
cache:false, //禁用AJAX数据缓存
sidePagination:'server', //服务端处理分页
queryParamsType:"undefined", //设置参数格式
showExport: true, //是否显示导出按钮
buttonsAlign: "right",//按钮位置
exportDataType:"basic", //导出的数据类型,支持basic、all 、selected
exportOptions:{
ignoreColumn:[0], //导出数据忽略第一列
fileName:'油井月报表', //导出数据的文件名
worksheetName:'sheet1',//表格工作区名称
tableName:'油井月报表',
excelstyles:['background-color','color','font-size','font-weight']
},
Icons:'glyphicon glyphicon-export', //出示
exportTypes:['json','xml','csv','xlsx','txt','sql','excel','pdf'], //导出类型
queryParams:function queryParams(params) {//设置查询参数
var param={
page:params.pageNumber, //首页页码
rows:params.pageSize, //每页的记录数
"wellInfo.wellId":$('#wellId').val(), //井编号
oilTimeFrom:$('#oilTimeFrom').val(), //开始日期
oilTimeTo:$('#oilTimeTo').val(), //截止日期
"area.areaId":$('#areaId option:selected').val()//作业区编号
};
return param;
},
columns:[/*{
checkbox:true
},*/{
title:'序号',
field:'oilId',
align:'center'
},{
title:'油井编号',
field:'wellInfo',
align:'center',
formatter:function (value,row,index) {
if (row.wellInfo){
return row.wellInfo.wellId;
}else{
return value;
}
}
},{
title:'生产日期',
field:'oilTime',
align:'center'
},{
title:'日产油量(t)',
field:'outOil',
align:'center'
},{
title:'日产液量(t)',
field:'outFluid',
align:'center'
},{
title:'日产水量(t)',
field:'outWater',
align:'center'
},{
title:'日产气量(立方米)',
field:'outGas',
align:'center',
},{
title:'含水率(%)',
field:'waterContent',
align:'center'
},{
title:'油气比(%)',
field:'oilGasRatio',
align:'center'
},{
title:'含盐量(mg/L)',
field:'oilSalinity',
align:'center'
},{
title:'动液面(m)',
field:'oilDynamic',
align:'center'
},{
title:'报警级别编号',
field:'alarmInfo',
align:'center',
formatter:function (value,row,index) {
if (row.alarmInfo){
return row.alarmInfo.alarmId;
}else{
return value;
}
}
},{
title:'油压(MPa)',
field:'oilPress',
align:'center'
},{
title:'套压(MPa)',
field:'casingPress',
align:'center'
},{
title:'回压(Mpa)',
field:'backPress',
align:'center'
},{
title:'报警备注',
field:'oilRemark',
align:'center'
}]
});
printFormatter 看到这个参数了吗,formatter是格式化显示的,需要再加一个printFormatter 是格式化打印的