LayUI的数据表格有三种渲染方式,方法渲染、自动渲染、转换数据表格。我用的最多的第一种,方法渲染,直接在HTML网页写一行代码然后剩下的业务逻辑和实现都交给Js去处理。这种方式个人感觉比较容易实现和发现问题,通过id把两者关联起来。下面的篇幅就是介绍这种方式的使用,另外两种也要了解,见到代码能看懂,知道原理是啥就行。下面的方式必须掌握。
示例:
var table = layui.table;
table.render({ elem: '#userTable' ,height: 'full-210' ,url: APP.restfulPrefix('/account/um_user/get_all_by_is_manage') //数据接口 ,where:{is_manager: 1, loginKey:sessionStorage.getItem("account_login_key")} ,page: {limit:50} //开启分页 ,cols: [[ //表头 {type:'checkbox',width:50, fixed: 'left'} ,{field: 'tenantId', title: '机构编码', width:120} ,{field: 'tenantName', title: '机构名称', width:120,} ,{field: 'id', title: '账号', width:120, sort: true,toolbar: '#id'} ,{field: 'realname', title: '姓名', width:100} ,{field: 'nickname', title: '昵称', width:100} ,{field: 'mobile', title: '手机', width:120} ,{field: 'email', title: '邮箱', width:150} ,{fixed: 'right', title: '管理',width:80, align:'cent