Layui 数据表格中动态添加下拉框 添加时间控件
layui表头 { title: ‘关联项目’, minWidth: 110, align: “center”, rowspan: 2, templet: “#SelectProject”}, { field: ‘ProjectID’, title: ‘关联项目结果’, width: 110, align: “center”, rowspan: 2, hide: true }, { field: ‘BulletinDate’, title: ‘日期’, minWidth: 110, align: “center”, rowspan: 2, edit: ‘text’, event: ‘editStartDate’},
列模板
js
//render加上防止遮挡 done: function (res, curr, count) {$(".td-select-table-sx").parent().css('overflow', 'visible');} // 监听修改update到表格中 form.on('select(ProjectSelect)', function (data) { var scoreId = $(data.elem).parent().parent().parent().find('[data-field="ProjectID"] div'); scoreId.text(data.value); // 其他的操作看需求 TODO var TabData = layui.table.cache["ReiDetailed"]; var index = $(data.elem).parents('tr').attr("data-index"); TabData[index].ProjectID = data.value; }); //ReiDetailed是表格ID //时间控件 table.on('tool(ReiDetailed)', function (obj) { var data = obj.data; if (obj.event === 'editStartDate') { var field = $(this).data('field'); laydate.render({ elem: this.firstChild , show: true //直接显示 , closeStop: this , done: function (value, date) { data[field] = value; obj.update(data); } }); } }); ``