layui表格数据统计
2024-10-20 08:25:30
//执行一个 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/
最新文章
- SVN迁项目
- nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 56; cvc-complex-type.2.4.c通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明
- UVALive 4043 Ants 蚂蚁(二分图最佳完美匹配,KM算法)
- MFC/VC++ 响应回车键的实现
- dedecms由子目录访问修改为根目录访问
- Java学习----对象的状态和行为
- nexus私服安装
- Aspose.Cells for .NET 8.5.0 工具类
- JAVA的高并发编程
- CF341C. Iahub and Permutations [DP 排列]
- CentOS安装编译Lua
- Opencv读取并获取视频属性
- python学习之装饰器-
- getCacheDir()、getFilesDir()、getExternalFilesDir()、getExternalCacheDir()
- Sum of Even Numbers After Queries LT985
- Zip包解压工具类
- Dubbo与Zookeeper在Window上的安装与简单使用
- c# Mongodb创建自增列
- VisualSVN+TortoiseSVN搭建版本控制系统教程
- 几个CSS-content的小例子