layui表格数据重载

<div> <div> <form action=""> <div> <div> <input type="text" required lay-verify="required" placeholder="请输入用户名" autocomplete="off"> </div> <button data-type="reload" >搜索</button> <button>添加</button> </div> </form> <div> <table lay-skin="nob"></table> </div> </div> </div>

js代码

layui.use('table', function(){ var table = layui.table; table.render({ elem: '#userTable', url:'${HPath}/sUser/SelectUserTable', cellMinWidth: 80, cols: [[ {field:'userID', title: '用户ID', sort: true}, {field:'userName', title: '用户名称'}, {field:'powerName', title: '权限名称'}, {field:'mailbox', title: '邮箱'}, {field:'operatUsers', title: '操作', templet: function(d){ var html = ''; html += '<button>修改</button>'; html += '<button>删除</button>'; return html }, fixed: 'right', width: 130 } ]], id:'userTableReload', limit: 10, page:true }); //根据条件查询表格数据重新加载 var $ = layui.$, active = { reload: function(){ //获取用户名 var demoReload = $('#userName'); //执行重载 table.reload('userTableReload', { page: { curr: 1 //重新从第 1 页开始 } //根据条件查询 ,where: { userName:demoReload.val() } }); } }; //点击搜索按钮根据用户名称查询 $('#selectbyCondition').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3aa850ec2bc443616705c47e5abf48e3.html