layui異步加載table表中某一列數(shù)據(jù)的例子
layui中table加載數(shù)據(jù)時 如果數(shù)據(jù)存放在不同數(shù)據(jù)表中 那樣一個請求拼接每行表格數(shù)據(jù) 然后統(tǒng)一返回 太慢
//頁面加載時請求 另一張表的數(shù)據(jù)
var slotGroup;
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 返回此列需要展示的數(shù)據(jù)
,{field: 'remark', title: '描述',templet: function (d) {
return getRemark(d.id)
} }
,{field: 'adState', title: '狀態(tài)'}
,{field: 'updateTime', title: '時間'}
,{title: '操作',width: 200, align: 'center', fixed: 'right', toolbar: '#table-forum-list'}
]]
,page: false
, text: {
none: '暫無相關(guān)數(shù)據(jù)'
}
, done: function(res, curr, count){
// console.log(res);
}
});
//遍歷展示一開始的數(shù)據(jù)
function getRemark(v) {
var showGroup = '';
if (v == null || v == undefined) return showGroup;
if (slotGroup != null && slotGroup != undefined) {
for (var i = 0; i < slotGroup.length; i++) {
if ( parseInt(slotGroup[i].id)== parseInt(v)) {
showGroup = slotGroup[i].pass_name;
return showGroup;
}
}
}
return showGroup;
}
以上這篇layui異步加載table表中某一列數(shù)據(jù)的例子就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- 關(guān)于Layui Table隱藏列問題
- layui table 表格上添加日期控件的兩種方法
- layui實(shí)現(xiàn)根據(jù)table數(shù)據(jù)判斷按鈕顯示情況的方法
- layui-table獲得當(dāng)前行的上/下一行數(shù)據(jù)的例子
- layui table單元格事件修改值的方法
- layui將table轉(zhuǎn)化表單顯示的方法(即table.render轉(zhuǎn)為表單展示)
- 解決layui table表單提示數(shù)據(jù)接口請求異常的問題
- layui table 表格模板按鈕的實(shí)例代碼
- layui table動態(tài)表頭 改變表格頭部 重新加載表格的方法
- layui table 列寬百分比顯示的實(shí)現(xiàn)方法
相關(guān)文章
js 限制數(shù)字 js限制輸入實(shí)現(xiàn)代碼
在工作中經(jīng)常會遇到j(luò)s限制輸入方面的要求,本文將詳細(xì)介紹其實(shí)現(xiàn)原理,需要的朋友可以參考下2012-12-12
JavaScript省市聯(lián)動實(shí)現(xiàn)代碼
這篇文章主要介紹了JavaScript省市聯(lián)動實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-02-02
基于webpack-hot-middleware熱加載相關(guān)錯誤的解決方法
下面小編就為大家分享一篇基于webpack-hot-middleware熱加載相關(guān)錯誤的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-02-02
原生javascript實(shí)現(xiàn)的一個簡單動畫效果
下面小編就為大家?guī)硪黄鷍avascript實(shí)現(xiàn)的一個簡單動畫效果。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-03-03
js 利用className得到對象的實(shí)現(xiàn)代碼
利用className得到對象的實(shí)現(xiàn)代碼,大家可以看下代碼的實(shí)現(xiàn)原理。2011-11-11

