layui异步加载table表中某一列数据的例子
layui中table加载数据时如果数据存放在不同数据表中那样一个请求拼接每行表格数据然后统一返回太慢
//页面加载时请求另一张表的数据
varslotGroup;
admin.req({
url:'请求地址'
,method:'POST'
,dataType:"json"
,async:false
,success:function(res){
slotGroup=res.data;
console.log(slotGroup)
}
});
table.render({
elem:'#LAY-ad_pass-list'
,url:'请求地址'//模拟接口
,cols:[[
{field:'id',title:'ID',sort:true}
,{field:'pass_name',title:'通道名称'}
,{field:'pass_code',title:'通道code'}
//注意::此处使用function返回此列需要展示的数据
,{field:'remark',title:'描述',templet:function(d){
returngetRemark(d.id)
}}
,{field:'adState',title:'状态'}
,{field:'updateTime',title:'时间'}
,{title:'操作',width:200,align:'center',fixed:'right',toolbar:'#table-forum-list'}
]]
,page:false
,text:{
none:'暂无相关数据'
}
,done:function(res,curr,count){
//console.log(res);
}
});
//遍历展示一开始的数据
functiongetRemark(v){
varshowGroup='';
if(v==null||v==undefined)returnshowGroup;
if(slotGroup!=null&&slotGroup!=undefined){
for(vari=0;i
以上这篇layui异步加载table表中某一列数据的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。