Based on the checked Field to determine whether it is selected
layui.config({ base: '/static/layui/' }).extend({ treeTable:
'treetable/treetable' }); layui.use(['treeTable'], function () { var $ = layui.
jquery; var treeTable = layui.treeTable; treeTable = $.extend(treeTable, {
config: { checkName: 'checked' } }); var insTb = treeTable.render({ elem:
'#demoTreeTb', height: '480px', tree: { iconIndex: 0, // In which column does the collapse icon appear isPidData:
true, // Is it id,pid Formal data idName: 'menuId', // id Field name pidName: 'parentId' //
pid Field name }, cols: [ { field: 'name', title: ' Node name ' }, { field: 'path', title:
' route ' }, { field: 'state', title: ' state ', templet: function (res) { if (res.state
== 0) { return ' disabled ' } else { return ' available ' } } }, { fixed: 'right', type:
'checkbox', width: 150 } ], reqData: function (data, callback) { //
Write it here ajax request , adopt callback Method callback data $.get('/system/resource/list', function (res) { if (
res.code == 0) { var data = res.data; for (var x in data) { console.log(data[x])
if (data[x].checked) { data[x]["LAY_CHECKED"] = 'true'; var index = res.data[x][
'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'); } } callback(res.data); } else callback(
res.msg); }); } }); // Listen for line tool events treeTable.on('tool(demoTreeTb)', function (obj) {
var data = obj.data; var id = data.id; console.log(data.id) if (obj.event ===
'remove') { } else if (obj.event === 'edit') { } }); var checkStatus; // check box
treeTable.on('checkbox(demoTreeTb)', function (obj) { console.log(insTb.
checkStatus()); }); $("#save").click(function () { console.log(checkStatus); })
});
Technology