在 layui 中,可通过以下步骤获取 table 表格选中行值:获取当前选中的所有行:layui.table.checkStatus('tableId');获取当前选中的行数据:let data = layui.table.checkStatus('tableId').data;获取当前选中的行索引:let index = layui.table.checkStatus('tableId').index。
如何使用 layui 获取 table 表格选中行值
在 layui 中,获取表格选中行值的方法如下:
1. 获取当前选中的所有行
layui.table.checkStatus('tableId');
2. 获取当前选中的行数据
let data = layui.table.checkStatus('tableId').data;
3. 获取当前选中的行索引
let index = layui.table.checkStatus('tableId').index;
其中,tableId 为表格的容器 ID。
示例代码:
layui.use('table', function () { var table = layui.table; // 获取表格实例 let instance = table.render({ elem: '#test-table', data: [{ id: 1, name: 'John Doe' }, { id: 2, name: 'Jane Doe' }], cols: [[{ type: 'checkbox' }, { field: 'id', title: 'ID' }, { field: 'name', title: '姓名' }]] }); // 获取当前选中的行 let data = table.checkStatus('test-table').data; // 输出选中行的姓名 console.log(data[0].name); // John Doe });
以上就是layui怎么获取table表格选中行值的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号