87,902
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../JS/Bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet" />
<link href="../JS/Bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<table id="table"
data-toggle="table"
data-height="460"
data-show-footer="true"
data-url="data1.json">
<thead>
<tr>
<th data-field="id" data-footer-formatter="idFormatter">ID</th>
<th data-field="name" data-footer-formatter="nameFormatter">Item Name</th>
<th data-field="price" data-footer-formatter="priceFormatter">Item Price</th>
</tr>
</thead>
</table>
</body>
</html>
<script src="../Scripts/jquery-3.0.0.min.js"></script>
<script src="../JS/Bootstrap/dist/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.js"></script>
<script>
function idFormatter() {
return 'Total'
}
function nameFormatter(data) {
return data.length
}
function priceFormatter(data) {
var field = this.field
return '$' + data.map(function (row) {
return +row[field].substring(1)
}).reduce(function (sum, i) {
return sum + i
}, 0)
}
</script>