layui表格數據統計


  //執行一個 table 實例
table.render({
elem: '#demo'
,height: 420
,url: '/demo/table/user/' //數據接口
,title: '用戶表'
,page: true //開啟分頁
,toolbar: 'default' //開啟工具欄,此處顯示默認圖標,可以自定義模板,詳見文檔
,totalRow: true //開啟合計行(在這里開啟合計)
,cols: [[ //表頭
{type: 'checkbox', fixed: 'left'}
,{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left', totalRowText: '合計:'}
,{field: 'username', title: '用戶名', width:80}
,{field: 'experience', title: '積分', width: 90, sort: true, totalRow: true}
,{field: 'sex', title: '性別', width:80, sort: true}
,{field: 'score', title: '評分', width: 80, sort: true, totalRow: true}//(需要合計的地方加上這個)
,{field: 'city', title: '城市', width:150}
,{field: 'sign', title: '簽名', width: 200}
,{field: 'classify', title: '職業', width: 100}
,{field: 'wealth', title: '財富', width: 135, sort: true, totalRow: true}
,{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'}
]]
,parseData: function(res){ //將原始數據解析成 table 組件所規定的數據
return {
"code": res.code, //解析接口狀態
"msg": res.msg, //解析提示文本
"count": res.count, //解析數據長度
"data": res.data, //解析數據列表
"totalRow": {
"score": "666"
,"experience": "999"
}
};
}
});
需要layui2.4+以上的版本

轉自 https://fly.layui.com/jie/64499/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM