layui table 复选框跳页后再回来保持原来选中的状(2)

layui.use("table", function(){ var table = layui.table; //设置初始选中项 var checkedIds = "1,2,3,4"; table.render({ elem: '#test', url:"./person/search", where: {"layuiCheckedIds": checkedIds }, ,cols: [[ {type:'checkbox', width:'10%'}, {field:'id', title: 'ID', width:'20%'}, {field:'name', title: '姓名', width:'15%'} ]], page: true, id:'idTest' }); //初始化选中项 table.initPageCheckedIds('idTest', checkedIds ); //监听表格复选框选择 table.on('checkbox(demo)', function(obj){ //设置多页面选中效果 //第一个参数表示table的id值,第二个参数表示复选框选中的数据,第三个参数表示要解析的是哪一个属性值(这里是将数据模型中的id属性进行解析)。 table.setLayuiPageCheckedIds('idTest',obj, "id"); //获取所有选中的id值(例如:“,1,2,5,7,3,15,22”) //alert(table.getLayuiPageCheckedIds('idTest')); }); });

以上这篇layui table 复选框跳页后再回来保持原来选中的状态示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

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

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