Layui<table>数据表格之外的数据渲染

有些时间使用layui渲染表格数据,可能不仅需要渲染table,也有可能需要做各种统计或者其他操作,这个时候值就不方便渲染。

找了很久解决办法,终的大悟,其实很简单,只需要引用layui的parseData 插件就可以实现,下面有例子!

var tableIns = table.render({
		elem : '#adminList',
		url : '',
		cellMinWidth : 95,
		page : true,
		method : 'post',
		height : "full-175",
		loading : true,
		id : "adminListTable",
		parseData : function(res) { //res 即为原始返回的数据
			$(".sum").val(res.data.sum);
			return {
				"code" : res.code, //解析接口状态
				"msg" : res.msg, //解析提示文本
				"count" : res.count, //解析数据长度
				"data" : res.data.listData //解析数据列表
			};
		},
		cols : [ [
				{type : "checkbox",fixed : "left",width : 50},
				{field : 'title',title : '房源标题',minWidth : 100,align : "center"},
				{field : 'quota',title : '期望金额(万元)',minWidth : 100,align : "center"},
				{field : 'name',title : '用款人姓名',minWidth : 100,align : "center"},
				{field : 'nikeName',title : '用款人昵称',minWidth : 100,align : "center"},
				{field : 'count',title : '房源投标量',minWidth : 100,align : "center"},
				{field : 'cost',title : '房源总收入(元)',minWidth : 100,align : "center"},
				{field : 'operationTime',title : '发布时间',minWidth : 165,align : "center"},
				{field : 'status',title : '房源状态',align : 'center',width : 100,
					templet : function(d) {
						var js = d.status;
						if (js == 0) {
							return "正常";
						} else if (js == 1) {
							return "结束";
						}
					}
				},
				{title : '操作',minWidth : 175,templet : '#adminListBar',fixed : "right",align : "center"}
			] ]
	});
查询前
刚进入时
2
条件过滤后

注意事项:该插件为 layui 2.4.0 开始新增!抓紧去更新尝试把!layui官网

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值