用户工具

站点工具


web:layui
  • layui.table
<table id="userTable" class="layui-hide" lay-filter="user"></table>
<script type="text/html" id="toolbar"><a class="layui-btn" lay-event="edit">编辑</a></script>
//渲染表格,ajax获取数据
params = new URLSearchParams(location.search);
value = params.get('name')  //location.replace,使用js获取页码再跳转
current = params.get('curr')||'1' //js获取第N页  
table.render({id:'userTable',elem:'#userTable',url:'listUser',cols:[[
{checkbox:true,fixed:true,width:'3%'}
,{field:'name',title:'姓名',sort:true,templet:function(v){}}
,{title:'操作',toolbar:'#toolbar',width:'25%'}
]],page: {curr: current} //页码初始化时加载第N页,点击下一页后更新current值
,done: function(res, curr, count){ current = curr; }
});
table.on('tool(user)', function(obj){
if(obj.event=='edit') alert(obj.data.name);
})
//跳转页码时传递当前页参数,其他页返回时带回此页码
href="showSubject?curr=${RequestParameters['curr']}" //freemarker方式获取第N页
location.replace("showSubject?curr="+current)  //js方式传递第N页的参数
//重新载入,页面置1
table.reload('userTable', { page:{curr:1},where:{name:'张三'} });
//直接载入数据,不分页,limit可以取data.length
table.render({id,elem,data:[],limit:100,cols,msg})
web/layui.txt · 最后更改: 2020/07/17 15:17 由 admin