码迷,mamicode.com
首页 > 其他好文 > 详细

easyUI的汇总列,在前端生成

时间:2017-09-14 18:30:45      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:product   blog   training   err   fun   i++   加载   tail   less   

1、easyUI初始化,启用汇总列,showFooter:true

2、后台json有默认的footer的值

{"total":28,"rows":[
    {"productid":"FI-SW-01","unitcost":10.00,"status":"P","listprice":36.50,"attr1":"Large","itemid":"EST-1"},
    {"productid":"K9-DL-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},
    {"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":28.50,"attr1":"Venomless","itemid":"EST-11"},
    {"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":26.50,"attr1":"Rattleless","itemid":"EST-12"},
    {"productid":"RP-LI-02","unitcost":12.00,"status":"P","listprice":35.50,"attr1":"Green Adult","itemid":"EST-13"},
    {"productid":"FL-DSH-01","unitcost":12.00,"status":"P","listprice":158.50,"attr1":"Tailless","itemid":"EST-14"},
    {"productid":"FL-DSH-01","unitcost":12.00,"status":"P","listprice":83.50,"attr1":"With tail","itemid":"EST-15"},
    {"productid":"FL-DLH-02","unitcost":12.00,"status":"P","listprice":63.50,"attr1":"Adult Female","itemid":"EST-16"},
    {"productid":"FL-DLH-02","unitcost":12.00,"status":"P","listprice":89.50,"attr1":"Adult Male","itemid":"EST-17"},
    {"productid":"AV-CB-01","unitcost":92.00,"status":"P","listprice":63.50,"attr1":"Adult Male","itemid":"EST-18"}
],"footer":[{"unitcost":合计,"listprice":0}]}

3、前台获取footer的值,然后修改,再刷新

 onLoadSuccess: function (data) {//表单加载完后再加载此方法
                sumline(data);
            }
//汇总列
        function sumline(data) {
            // var rows = $(‘#dg‘).datagrid(‘getRows‘)//获取当前的数据行
            var ptotal = 0//
            for (var i = 0; i < data.rows.length; i++) {
                ptotal += parseInt(data.rows[i].listprice);
            }
            //新增一行显示统计信息
            //$(‘#list‘).datagrid(‘appendRow‘, { strLearningDutyName: ‘<b>合计:</b>‘, trainingNum: ptotal, strTrainingTimes: utotal });
            var rows = $(‘#list‘).datagrid(‘getFooterRows‘);
            rows[0]["listprice"] = ptotal;
            $(‘#list‘).datagrid(‘reloadFooter‘);
        }

 

easyUI的汇总列,在前端生成

标签:product   blog   training   err   fun   i++   加载   tail   less   

原文地址:http://www.cnblogs.com/hongmaju/p/7521453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!