table的合计行现在可以指定保留的小数点位了。如果不指定的话就是默认的2位,可以通过参数 totalRowDecimalScale 来指定。
This commit is contained in:
parent
c0f555adcf
commit
4d400a369d
@ -177,7 +177,7 @@ body{padding: 20px; /*overflow-y: scroll;*/}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="../src/layui.js" src="//layui.hcwl520.com.cn/layui-v2.4.5/layui.js" charset="utf-8"></script>
|
||||
<script src="../src/layui.js" charset="utf-8"></script>
|
||||
<script>
|
||||
layui.use('table', function(){
|
||||
var table = layui.table;
|
||||
@ -397,7 +397,8 @@ layui.use('table', function(){
|
||||
,{field: 'sign', title: '签名', width: 150}
|
||||
,{field: 'sex', title: '性别', width: 80}
|
||||
,{field: 'city', title: '城市', width: 100}
|
||||
,{field: 'experience', title: '积分', width: 80, sort: true}
|
||||
// ,{field: 'experience', title: '积分', width: 80, sort: true}
|
||||
,{field: 'experience', title: '积分', width: 80, sort: true, totalRow: true, totalRowDecimalScale: 20}
|
||||
]]
|
||||
,data: [{
|
||||
"id": "10001"
|
||||
@ -497,6 +498,7 @@ layui.use('table', function(){
|
||||
,page: true //是否显示分页
|
||||
,limits: [3,5,10]
|
||||
,limit: 3 //每页默认显示的数量
|
||||
,totalRow: true
|
||||
//,loading: false //请求数据时,是否显示loading
|
||||
});
|
||||
|
||||
|
@ -951,8 +951,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
//td内容
|
||||
var content = function(){
|
||||
if( item3.totalRowDecimalScale == null || isNaN(item3.totalRowDecimalScale) ||
|
||||
item3.totalRowDecimalScale < 0 || item3.totalRowDecimalScale > 10 ){
|
||||
// 如果检测到非法值就重设为2。至于非法值的定义这里是我自己定义的。
|
||||
item3.totalRowDecimalScale = 2;
|
||||
}
|
||||
var text = item3.totalRowText || ''
|
||||
,thisTotalNum = parseFloat(totalNums[field]).toFixed(2)
|
||||
,thisTotalNum = parseFloat(totalNums[field]).toFixed(item3.totalRowDecimalScale)
|
||||
,tplData = {};
|
||||
|
||||
tplData[field] = thisTotalNum;
|
||||
|
Loading…
Reference in New Issue
Block a user