如下图所示的二层组合表头
来人,上代码!
javascript
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
search: false,
showToggle: false,
showColumns: false,
showExport: false, commonSearch: false,
columns: [
[
{field: 'nickname', title: __('昵称'), valign:"middle", align:"center", colspan: 1, rowspan: 2, operate: false},
{field: 'createtime',title: __('创建时间'),autocomplete: false,valign:"middle",align:"center",colspan: 1,rowspan: 2,formatter: Table.api.formatter.datetime, operate: false},
{title: "今日数据",valign:"middle", align:"center", colspan: colspan(), rowspan: 1,visible: visible()},
],[
{field: 'money_sum_today', title: __('微信'), operate: false,align:'center',halign:"center",visible: visible()},
{field: 'score_sum_today', title: __('支付宝'), operate: false,align:'center',halign:"center",visible: visible()},
],
]
});
要点讲解:
columns下每一个数组代表一层
像图中的例子,昵称和创建时间没有二层表头,需要将rowspan字段设为2,当遇到第一个rowspan为1的一层表头,二层表头就会从这里开始罗列显示