在网上找了很多代码,说要这个要那个的,试了好几回都不行
因为回传数据data中的LAY_CHECKED这个数据是通过case when条件语句判断的到的,不能在sql语句中直接是用true和false,必须封装成字符串或者1和0,我选择了封装成字符串
以下为table的渲染代码,在最后的done:function里把if语句中改成你的判断条件,tableid改成你要渲染的table的id
table.render({
elem: '#rfidTableId',
url: '/Table/Id',
toolbar: '#toolbarDemo',
defaultToolbar: ['filter', 'exports'],
//省略数据的部分
done : function(res, curr, count){
$.each(res.data, function(index, item) {
if (item.laycheck=="true") {
$("div[lay-id='rfidTableId'] td .layui-form-checkbox").eq(index).click();
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
//$('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
});
}
});