function initTable(table, stationIds) {
//展示已知数据
table.render({
......,//省略
done: function (res,curr,count) {
var ids = stationIds.split(',');
for (var i = 0; i < res.data.length; i++) {
for (var j = 0; j < ids.length; j++) {
//数据id和要勾选的id相同时checkbox选中
if (res.data[i].stationID == ids[j]) {
//这里才是真正的有效勾选
res.data[i]["LAY_CHECKED"] = 'true';
//找到对应数据改变勾选样式,呈现出选中效果
var index = res.data[i]['LAY_TABLE_INDEX'];
$('.layui-table-fixed-l tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('.layui-table-fixed-l tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
}
}
console.log(res);
}
});
}
Layui :获取表格数据时根据参数选中复选框select
最新推荐文章于 2024-03-07 13:49:39 发布