layui table 详细讲解

 layui.use('table', function () {
            var table = layui.table;
            /*第一种原始写法*/
            /*
            table.render({
                id: 'laydictsList',
                elem: '#test',
                url: areasURL + "/base_dics/LayuigetPageList",
                cellMinWidth: 80,//全局定义常规单元格的最小宽度,layui 2.2.1 新增
                where: { txtFullName: null },
                page: true,
                //toolbar:'barDemo',
                limit: 10,
                limits: [2, 5, 10, 20, 30],
                text: {
                    none: '暂无相关数据!'//默认无数据
                },
                cols: [[
                  { type: 'checkbox', LAY_CHECKED: false },
                  { field: 'dicsid', width: 80, title: 'ID', sort: true, hide: true },
                  { field: 'code', width: 80, title: '编号' },
                  { field: 'sortnum', width: 80, title: '序号', sort: true },
                  { field: 'fullname', width: 80, title: '名称' },
                  { field: 'diccategoryname', title: '所属类别', width: '30%', minWidth: 100 }, //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
                  { field: 'experience', title: '操作' }
                ]]
            });
        });
        */
            /*第二种改进版*/
            table.render({
                id: 'laydictsList',
                elem: '#test',
                url: areasURL + "/base_dics/getPageList",
                method: "post",
                request: {
                    pageName: 'PageNum', //页码的参数名称,默认:page
                    limitName: 'PageSize' //每页数据量的参数名,默认:limit
                },
                response: {
                    statusName: 'ReturnType', //数据状态的字段名称,默认:code
                    statusCode: true,//成功的状态码,默认:0
                    msgName: 'ReturnMsg', //状态信息的字段名称,默认:msg
                    countName: 'ReturnCount', //数据总数的字段名称,默认:count
                    dataName: 'ReturnData', //数据列表的字段名称,默认:data
                },
                cellMinWidth: 80,//全局定义常规单元格的最小宽度,layui 2.2.1 新增
                where: { txtFullName: null },
                page: true,
                //toolbar:'barDemo',
                limit: 10,
                limits: [2, 5, 10, 20, 30],
                text: {
                    none: '暂无相关数据!'//默认无数据
                },
                cols: [[
                  { type: 'checkbox', LAY_CHECKED: false },
                  { field: 'dicsid', width: 80, title: 'ID', sort: true, hide: true },
                  { field: 'code', width: 80, title: '编号' },
                  { field: 'sortnum', width: 80, title: '序号', sort: true },
                  { field: 'fullname', width: 80, title: '名称' },
                  { field: 'diccategoryname', title: '所属类别', width: '30%', minWidth: 100 }, //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
                  { field: 'experience', title: '操作' }
                ]]
            });
        });
posted on 2018-06-19 16:25  笨小孩做开发 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/dullbaby/p/9199144.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值