footerFormatter中如果return的值包含'.'就不显示怎么办

able_77 2019-08-26 03:04:51


不得已只能把.改成., 有其他的方法么
...全文
196 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hello World, 2019-08-27
  • 打赏
  • 举报
回复
BootStrap-table的footerformater并没有value,row,index的参数,只有传递data,不知道你用的哪个版本?


并且包含小数也没有问题的:

<!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>
able_77 2019-08-26
  • 打赏
  • 举报
回复
引用 3 楼 Hello World, 的回复:
你贴出完整的代码,比如这段函数是谁调用的,返回之后怎么使用的,光这段看不出问题的
谢谢 已经解决了。发生这个问题的根本原因不知道 bootstrapTable,定义columns -> footerFormatter 设置自定义方法xx(str) return 返回的字符串不可包含"." 但是如果定义的方法是bootstrapTable的默认函数 xx(value, row, index) return 任意字符串都没有问题。
Hello World, 2019-08-26
  • 打赏
  • 举报
回复
你贴出完整的代码,比如这段函数是谁调用的,返回之后怎么使用的,光这段看不出问题的
able_77 2019-08-26
  • 打赏
  • 举报
回复
引用 1 楼 Hello World, 的回复:
后面怎么弄的?
Formatter(value, row, index) 要用自带的这种方法,出来的就正常 自己定义的方法就会出现这种问题。。。 有点莫名其妙
Hello World, 2019-08-26
  • 打赏
  • 举报
回复
后面怎么弄的?

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧