layui获取选中行数据的实例讲解
更新时间:2018年08月19日 13:43:57 作者:BooleanIsTrue
今天小编就为大家分享一篇layui获取选中行数据的实例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
第一步: 在jsp文件中设置按钮
<div class="layui-btn-group demoTable"> <button class="layui-btn" data-type="getCheckData">获取选中行数据</button> <button class="layui-btn" data-type="getCheckLength">获取选中数目</button> <button class="layui-btn" data-type="isAll">验证是否全选</button> </div>
第二步:在jsp文件中创建表格
<table class="layui-table" lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo">
<thead>
<tr>
<th lay-data="{type:'checkbox', fixed: 'left'}"></th>
<th lay-data="{field:'id', width:80, sort: true, fixed: true}">ID</th>
<th lay-data="{field:'username', width:80}">用户名</th>
<th lay-data="{field:'sex', width:80, sort: true}">性别</th>
<th lay-data="{field:'city', width:80}">城市</th>
<th lay-data="{field:'sign', width:160}">签名</th>
<th lay-data="{field:'experience', width:80, sort: true}">积分</th>
<th lay-data="{field:'classify', width:80}">职业</th>
<th lay-data="{field:'wealth', width:135, sort: true}">财富</th>
<th lay-data="{field:'score', width:80, sort: true, fixed: 'right'}">评分</th>
<th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th>
</tr>
</thead>
</table>
第三步:写js,监听事件
<script>
layui.use('table', function(){
var table = layui.table;
var $ = layui.$, active = {
getCheckData: function(){ //获取选中数据
var checkStatus = table.checkStatus('idTest')
,data = checkStatus.data;
layer.alert(JSON.stringify(data));
}
};
</script>
以上这篇layui获取选中行数据的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
javascript利用控件对windows的操作实现原理与应用
假如要发送汉字的聊天框的内容的话,我们也要从windows消息机制下手,先找到聊天消息的句柄(可以利用findwindow函数或者用spy工具哈),然后在找到上面的聊天框的句柄,接着我们就可以想这个句柄发送WM_SETTEXT的消息了2012-12-12
解决iframe的frameborder在chrome/ff/ie下的差异
最近的项目中使用了动态创建iframe的js方法,发现iframe.frameborder="0"在IE7下不管用,而chrome/ff都正常的,很是郁闷。2010-08-08


最新评论