layui table 詳細講解


 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         });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM