当前位置: 首页 > news >正文

layui Table单元格编辑支持Enter键换行,包括下拉框单元格

layui Table表格编辑支持Enter键换行

  • 可编辑单元格
$(".layui-table td").keydown(function (e) {//	console.log("111",e);var index = $(this).index(),tr = $(this).parent('tr'),isKeydown = (event.type == "keydown");if (e.code == "Enter") {isKeydown && tr['next']().children('td').eq(index).click();}
});

单元格中包含下拉框

layui.use(['dropdown', 'util', 'layer', 'table', 'laydate', 'form'], function () {var table = layui.table,laydate = layui.laydate,form = layui.form,layer = layui.layer;// 根据返回数据中某个字段来判断开启该行的编辑var editable = function(d){if(d.mark === "02") return 'text'; // 这里假设以 editable 字段为判断依据};table.render({elem: '#' + inspectionTable, data: tableData,toolbar: '#toolbarHeader', cols: [[{align: 'center', field: 'inspectionFeatureName', width: 150, title: '检验项目'}, {align: 'center', field: 'inspectionStandard', width: 150, title: '检验标准描述'}, {align: 'center', field: 'inspectionValue', width: 120, title: '检验结果', edit: editable ,templet: '#inspectionValue-select' }, {fixed: 'right',  width: 100, align:'left', toolbar: '#operateBar',title: '操作'}]], loading: true, height: 'full',done: function(res, curr, count){var options = this;console.log(res,curr,count)// 获取当前行数据 - 自定义方法table.getRowData = function(tableId, elem){var index = $(elem).closest('tr').data('index');return table.cache[tableId][index] || {};};// 监听表格内所有单元格的 keydown 事件//$(".layui-table td[data-field='inspectionValue']").keydown(function (e) {$(".layui-table td").keydown(function (e) {//	console.log("111",e);var index = $(this).index(),tr = $(this).parent('tr'),isKeydown = (event.type == "keydown");if (e.code == "Enter" || e.keyCode == 13 || e.keyCode == 108) {//	console.log("enter",index,tr.index());if(isKeydown && tr['next']().children('td').eq(index).find('select').length>0){console.log(tr['next']().children('td').eq(index).find('select'))tr['next']().children('td').eq(index).find('select').next().find('input').focus().click()}else{isKeydown && tr['next']().children('td').eq(index).click();}}});}});
})
http://www.lryc.cn/news/528499.html

相关文章:

  • Swoole的MySQL连接池实现
  • 无人机红外热成像:应急消防的“透视眼”
  • 【redis】Redis操作String类型key的发生了什么?
  • hdfs之读写流程
  • 研发的立足之本到底是啥?
  • Baklib揭示内容中台与人工智能技术的创新协同效应
  • 智慧消防营区一体化安全管控 2024 年度深度剖析与展望
  • 自定义数据集,使用 PyTorch 框架实现逻辑回归并保存模型,然后保存模型后再加载模型进行预测
  • UE5 特效
  • CMAKE工程编译好后自动把可执行文件传输到远程开发板
  • Windows 程序设计7:文件的创建、打开与关闭
  • 策略模式 - 策略模式的使用
  • 具身智能研究报告
  • Windows安装Milvus
  • Excel分区间统计分析(等步长、不等步长、多维度)
  • 宝塔mysql数据库容量限制_宝塔数据库mysql-bin.000001占用磁盘空间过大
  • LeetCode 2412.完成所有交易的初始最少钱数:【年度巨献】举例说明(讲明白),由难至简(手脚不乱),附Python一行版
  • 多人-多agent协同可能会挑战维纳的反馈
  • Go学习:类型转换需注意的点 以及 类型别名
  • C语言中的局部变量和全局变量有什么区别?
  • 价值交换到底在交换什么
  • C++传送锚点的内存寻址:内存管理
  • Prompt提示词完整案例:让chatGPT成为“书单推荐”的高手
  • 基于django的智能停车场车辆管理深度学习车牌识别系统
  • 【Proteus仿真】【51单片机】简易计算器系统设计
  • 洛谷P3884 [JLOI2009] 二叉树问题(详解)c++
  • 《Foundation 起步》
  • 【hot100】刷题记录(6)-轮转数组
  • Android createScaledBitmap与Canvas通过RectF drawBitmap生成马赛克/高斯模糊(毛玻璃)对比,Kotlin
  • ThinkPad E480安装Ubuntu 18.04无线网卡驱动