溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

layui 對(duì)table中的數(shù)據(jù)進(jìn)行轉(zhuǎn)義的實(shí)例

發(fā)布時(shí)間:2020-09-06 12:22:15 來(lái)源:腳本之家 閱讀:244 作者:kerw1nKwan 欄目:web開發(fā)

方法一 通過(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è)參考,也希望大家多多支持億速云。

向AI問(wèn)一下細(xì)節(jié)

免責(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)容。

AI