LayuiTablejs模拟选中checkbox的例子-创新互联
思路,根据 data-index 找到 点击到的tr,获取tr下的 div,js 模拟点击
创新互联建站从2013年开始,是专业互联网技术服务公司,拥有项目网站制作、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元葫芦岛做网站,已为上家服务,为葫芦岛各地企业和个人服务,联系电话:028-86922220function 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(); } }); }); }
分享名称:LayuiTablejs模拟选中checkbox的例子-创新互联
转载来于:http://azwzsj.com/article/cdejdi.html