layui默認選中table的CheckBox復選框


如何根據條件判斷是否默認選中table表格前面的復選框

table.render({
elem: '#userTable'
, url: '../sysRole/getUserList'
, title: '用戶列表'
, page: true //開啟分頁
, cols: [[
{type:'checkbox'}
, {field: 'userName',sort: true, title: '用戶名稱'}
, {field: 'account',sort: true, title: '登錄賬戶'}
, {field: 'deleteFlg',sort: true, title: '是否啟用'}
]]
,done: function(res, page, count){
//可以自行添加判斷的條件是否選中
//這句才是真正選中,通過設置關鍵字LAY_CHECKED為true選中,這里只對第一行選中
res.data[0]["LAY_CHECKED"]='true';
//下面三句是通過更改css來實現選中的效果
var index= res.data[0]['LAY_TABLE_INDEX'];
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
});

 

 

轉載https://blog.csdn.net/readyyy/article/details/82971723


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM