zl程序教程

您现在的位置是:首页 >  其它

当前栏目

layui table 详细讲解

详细 Table 讲解 layui
2023-09-27 14:26:14 时间
 1  layui.use('table', function () {
 2             var table = layui.table;
 3             /*第一种原始写法*/
 4             /*
 5             table.render({
 6                 id: 'laydictsList',
 7                 elem: '#test',
 8                 url: areasURL + "/base_dics/LayuigetPageList",
 9                 cellMinWidth: 80,//全局定义常规单元格的最小宽度,layui 2.2.1 新增
10                 where: { txtFullName: null },
11                 page: true,
12                 //toolbar:'barDemo',
13                 limit: 10,
14                 limits: [2, 5, 10, 20, 30],
15                 text: {
16                     none: '暂无相关数据!'//默认无数据
17                 },
18                 cols: [[
19                   { type: 'checkbox', LAY_CHECKED: false },
20                   { field: 'dicsid', width: 80, title: 'ID', sort: true, hide: true },
21                   { field: 'code', width: 80, title: '编号' },
22                   { field: 'sortnum', width: 80, title: '序号', sort: true },
23                   { field: 'fullname', width: 80, title: '名称' },
24                   { field: 'diccategoryname', title: '所属类别', width: '30%', minWidth: 100 }, //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
25                   { field: 'experience', title: '操作' }
26                 ]]
27             });
28         });
29         */
30             /*第二种改进版*/
31             table.render({
32                 id: 'laydictsList',
33                 elem: '#test',
34                 url: areasURL + "/base_dics/getPageList",
35                 method: "post",
36                 request: {
37                     pageName: 'PageNum', //页码的参数名称,默认:page
38                     limitName: 'PageSize' //每页数据量的参数名,默认:limit
39                 },
40                 response: {
41                     statusName: 'ReturnType', //数据状态的字段名称,默认:code
42                     statusCode: true,//成功的状态码,默认:0
43                     msgName: 'ReturnMsg', //状态信息的字段名称,默认:msg
44                     countName: 'ReturnCount', //数据总数的字段名称,默认:count
45                     dataName: 'ReturnData', //数据列表的字段名称,默认:data
46                 },
47                 cellMinWidth: 80,//全局定义常规单元格的最小宽度,layui 2.2.1 新增
48                 where: { txtFullName: null },
49                 page: true,
50                 //toolbar:'barDemo',
51                 limit: 10,
52                 limits: [2, 5, 10, 20, 30],
53                 text: {
54                     none: '暂无相关数据!'//默认无数据
55                 },
56                 cols: [[
57                   { type: 'checkbox', LAY_CHECKED: false },
58                   { field: 'dicsid', width: 80, title: 'ID', sort: true, hide: true },
59                   { field: 'code', width: 80, title: '编号' },
60                   { field: 'sortnum', width: 80, title: '序号', sort: true },
61                   { field: 'fullname', width: 80, title: '名称' },
62                   { field: 'diccategoryname', title: '所属类别', width: '30%', minWidth: 100 }, //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
63                   { field: 'experience', title: '操作' }
64                 ]]
65             });
66         });