layui获取选中行数据
2017-12-05 14:03
211 查看
第一步: 在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>
<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获取选中行数据的实例讲解
- C# Dev GridView 获取选中分组下的所有数据行
- datagridview 获取选中行号 数据,判断是不是选中了一行
- layui监听select下拉框获取数据通过doT.js加载页面多选框
- 如何获取datagridview中checkbox选中的多行数据
- jquery获取table指定行和列的数据(当前选中行、列)
- jquery获取table指定行和列的数据方法(当前选中行、列)
- 1.获取选中数据:
- ListView绑定数据,获取选中的数据
- Jquery DataTables 获取表格数据及选中行数据
- droplist在后台绑定数据,在后天怎么获取选中的值?
- 获取到AdvancedDataGrid选中行的全部数据呢
- c#获取listview当前选中行的数据
- easyui 获取数据表格中选中行的数据 Get selected row data from...
- C#中listview允许选中整行,并获取选中行数据
- [Extjs6]获取gridpanel内选中的数据
- C#之获取ListView当前选中的行的数据!...
- easyui获取数据表格中选中行的数据
- 获取easyui-datagrid中选中的数据,并遍历得到目标数据
- asp.net实现 gridview 鼠标单击任意字段选中一行 ,并获取数据