zoukankan      html  css  js  c++  java
  • 【layui】tepmlet 格式化 table 数据

    代码如下所示

    <script src="/static/vendor/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
     
    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;
    
            table.render({
                elem: '#currentTableId',
                url: '/user/queryjson',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    {type: "checkbox",  50},
                    {field: 'id',  80, title: 'ID', sort: true},
                    {field: 'name',  80, title: '用户名'},
                    {field: 'sex',  80, title: '性别', sort: true, templet: sexFormat},
                    {field: 'tel',  120, title: '联系方式'},
                    {field: 'addr',  120, title: '地址'},
                    {field: 'birthday',  180, title: '生辰', templet: birFormat},
                    {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 15,
                page: true,
                skin: 'line'
            });
            // 格式化显示男女信息,后端返回 true 或者 false,这里做判断
            function sexFormat(d) {
                var str;
                if (d.sex) {
                    str = '男';
                } else {
                    str = '女';
                }
                return str;
            }
     	 			// 格式化显示日期,调用layui.util 工具集,参考:https://www.layui.com/doc/modules/util.html
            function birFormat(d) {
                birday = layui.util.toDateString(d.birthday, "yyyy-MM-dd");
                return birday;
            }
        });
    </script>
    

    参考

    https://m.yisu.com/zixun/12217.html

  • 相关阅读:
    Callable的Future模式
    并发队列
    并发工具类
    线程池
    并发编程专题
    侧边栏:内有友链,分类等等
    脑残错误记录
    博主的OI流水账
    NOI2019游记
    NOI数论姿势瞎总结(Pi也没有)
  • 原文地址:https://www.cnblogs.com/UncleZhao/p/14228874.html
Copyright © 2011-2022 走看看