$('#table').bootstrapTable({
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'name',
title: 'Item Name'
},
{
field: 'price',
title: 'Item Price'
},
{
field: 'color',
title: 'Item Color'
},
{
field: 'size',
title: 'Item Size'
},
{
field: 'discount',
title: 'Item Discount'
}],
data: [{
id: 1,
name: 'Item 1',
price: '$1',
color: 'Red',
size: 'XL',
discount: '20%'
},{
id: 2,
name: 'Item 2',
price: '$2',
color: 'Green',
size: 'L',
discount: '30%'
},{
\t id: 'Total Items',
\t name: 2
}]
});
$('#table').bootstrapTable('mergeCells', {
\t index: 2,
\t field: 'name',
\t colspan: 5
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.css" rel="stylesheet"/>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<table id="table"></table>
初始化'一些數據data'變量。 –