表头列名转行
首先为所有单元格添加样式保证单元格中内容水平居中
/*水平居中*/
th{
vertical-align: middle !important;
}
在需要转行的列名中添加<br/>
标签
var templateTableParams = {
classes: "table table-bordered table-hover",
url: "后台访问路经",
method: 'post',
contentType: "application/x-www-form-urlencoded",
dataType: "json",
cache: false, //是否使用缓存,默认为true
striped: true, //是否显示行间隔色
singleSelect: true, //单选
clickToSelect: true, //是否启用点击选中行
queryParams:function () {
var params = {
maindjh: $('#maindjh').val()
};
return params;
},
columns: [
{ checkbox: true },
{ title: "序号", align:'center', halign:"center", formatter: function (value, row, index) { return index + 1; }},
{ field: 'jhyc', title: "计划月次",align:"center",halign:"center"},
{ field: 'lxdh', title:"计划单号",halign:"center", formatter :'paramsMatter'},
{ field: 'gyfl', title: "物资分类",halign:"center",align:"center" , formatter :'paramsMatter'},
{ field: 'itemCode', title: "物资编码",halign:"center", sortable:true, formatter :'paramsMatter' },
{ field: 'itemName', title: "物资名称",halign:"center" , sortable:true,formatter :'paramsMatter'},
{ field: 'cz', title: "物资属性" ,halign:"center" , formatter :'paramsMatter' },
{ field: 'dw', title: "计量<br/>单位" ,align:'center',halign:"center" },
{ field: 'xqsl', title: "需求数量",halign:"center",align:'right'}
],
cardView:(function(){ return /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent); })(),
onlyInfoPagination:false,//显示总记录数 必须打开pagination=true
pagination: false, //显示分页
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize:10, //每页记录数
pageList:[5,10,20], //可供选择的每页的行数
idField: 'id',
uniqueId: 'id',
smartDisplay:false,
onPostBody:function (data) {
},
onLoadSuccess: function(data) {
}
};
页面效果展示