layui table行点击tr_LayUI数据表格行单击事件中选中
2019年9月5日11:19:17
實(shí)現(xiàn)思路
直接修改復(fù)選框選中狀態(tài)和偽復(fù)選框(DIV)Class
但是調(diào)用checkStatus獲取不到選中的行
查看底層源代碼checkStatus方法的實(shí)現(xiàn)是緩存數(shù)據(jù)中的屬性來判斷是否選中
所以循環(huán)緩存數(shù)據(jù),用index找到操作數(shù)據(jù)修改,再次獲取選中行就可以獲取到了
table.on(‘row(test)‘,function(obj){
var flag = !obj.tr.find(‘:checkbox:first‘).attr(‘checked‘);
obj.tr.find(‘:checkbox‘).attr(‘checked‘,flag);
if(flag){
obj.tr.find(‘.layui-form-checkbox‘).addClass(‘layui-form-checked‘);
}else{
obj.tr.find(‘.layui-form-checkbox‘).removeClass(‘layui-form-checked‘);
}
layui.each(table.cache.userTable,function(i,l){
if(obj.tr.index()==l.LAY_TABLE_INDEX){
l.LAY_CHECKED=flag;
}
});
});
原文:https://www.cnblogs.com/wangfeii/p/11464726.html
總結(jié)
以上是生活随笔為你收集整理的layui table行点击tr_LayUI数据表格行单击事件中选中的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android 前台服务自定义布局不显示
- 下一篇: WordPress漏洞扫描工具WPSca