easyUI的彙總列,在前端生成

一、easyUI初始化,啓用匯總列,showFooter:truejson

二、後臺json有默認的footer的值app

{"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}]}

三、前臺獲取footer的值,而後修改,再刷新less

 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');
        }
相關文章
相關標籤/搜索