您好,登錄后才能下訂單哦!
方法一 通過(guò)done回調(diào)進(jìn)行遍歷:
//方法級(jí)渲染 table.render({ id: 'demoList', elem: '#demoList' , url: 'showDemoList' , cols: [[ {checkbox: true, fixed: true, width: '10%'} , {field: 'id', title: '編號(hào)', width: '15%', sort: true} , {field: 'pipe_id', title: '機(jī)構(gòu)ID', width: '15%'} , {field: 'bank_id', title: '銀行ID', width: '10%'} , {field: 'pipe_cost', title: '成本', width: '10%'} , {field: 'status', title: '狀態(tài)', width: '20%'} , {field: 'remark', title: '操作', width: '20%', toolbar: '#toolBar'} ]], done: function (res, curr, count) { //如果是異步請(qǐng)求數(shù)據(jù)方式,res即為你接口返回的信息。 //如果是直接賦值的方式,res即為:{data: [], count: 99} data為當(dāng)前頁(yè)數(shù)據(jù)、count為數(shù)據(jù)總長(zhǎng)度 $("[data-field='status']").children().each(function () { if ($(this).text() == '0') { $(this).text('有效'); } else if ($(this).text() == '1') { $(this).text('無(wú)效'); } }); } , page: true , height: 'full-83' });
方法二 通過(guò)layui的templet模板實(shí)現(xiàn):
, {field: 'status', title: '狀態(tài)', width: '20%',templet:'#status'} <script type="text/html" id="status"> {{# if(d.status=='0'){ }} 有效 {{# }else{ }} 無(wú)效 {{# } }} </script>
以上這篇layui 對(duì)table中的數(shù)據(jù)進(jìn)行轉(zhuǎn)義的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。