时间:2020-10-12 09:32:44 | 栏目:JavaScript代码 | 点击:次
思路,根据 data-index 找到 点击到的tr,获取tr下的 div,js 模拟点击
function iniTable() { layui.use('table', function(){ var table = layui.table; //展示已知数据 table.render({ elem: tableid ,cols: [[ //标题栏 {type:'checkbox',id:'goodsLimitSeqNo'} , {field: 'goodsLimitSeqNo', title: '序号',event: 'setSign', width: 50} ,{field: 'licTypeCode', title: '许可证类别代码',event: 'setSign', width: 140} ,{field: 'licTypeName', title: '许可证类别名称', event: 'setSign',width: 250} ,{field: 'licenceNo', title: '许可证编号', event: 'setSign',width: 150} ,{field: 'licWrtofDetailNo', title: '核销货物序号', event: 'setSign',width: 150} ,{field: 'licWrtofQty', title: '核销数量', event: 'setSign',width:90} ]] ,data: [] ,skin: 'line' //表格风格 ,even: true //,page: true //是否显示分页 //,limits: [5, 7, 10] //,limit: 5 //每页默认显示的数量 }); table.on('edit(goodslicencetable)', function(obj){ var value = obj.value //得到修改后的值 ,data = obj.data //得到所在行所有键值 ,field = obj.field; //得到字段 layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为:'+ value); }); table.on('checkbox(goodslicencetable)', function(obj){ console.log(obj) }); //监听单元格事件 table.on('tool(goodslicencetable)', function(obj){ var data = obj.data; // console.log(obj); if(obj.event == 'setSign'){ $('#customGoodslicfrm').find("input[name='goodsLimitSeqNo']").val(data.goodsLimitSeqNo); $('#customGoodslicfrm').find("select[name='licTypeCode']").val(data.licTypeCode); $('#customGoodslicfrm').find("input[name='custom_combobox_input_licTypeCode']").val(data.licTypeCode+'-'+data.licTypeName); $('#customGoodslicfrm').find("input[name='licenceNo']").val(data.licenceNo); $('#customGoodslicfrm').find("input[name='licWrtofDetailNo']").val(data.licWrtofDetailNo); $('#customGoodslicfrm').find("input[name='licWrtofQty']").val(data.licWrtofQty); var index = data.goodsLimitSeqNo-1; var td = $('#goodslicencetable').next().find("tr[data-index='"+index+"'] div.layui-form-checkbox"); td.click(); } }); }); }
var td = $('#goodslicencetable').next().find("tr[data-index='"+index+"'] div.layui-form-checkbox"); td.click();
获取 目标 tr div ,模拟click。