首次加载进入页面,如图:

注:Table是在js中拼接字符串循环动态添加的(拼接字符串,详见之前随笔)

点击Line2 checkbox后,效果如图:

实现的效果就是: 点击checkbox — 显示本行的其他列的textbox,同时动态新增下一行NO行数+1,其他列的textbox隐藏;

取消checkbox —remove本行的所有数据,同时下面的一行向上移,NO行数-1;

实现的js代码:

   function ShowEdit(obj) {
//获取当前行数
var num = obj.id;
num = $.trim(num.replace("gvItem_ck_", ""));
if ($.trim($(obj).attr("id")) == "gvItem_ck_0") {
$(obj).attr("checked", true);
return;
}
if ($(obj).is(":checked") == true) {//点击checkbox
$($(obj).parent().parent("tr")).each(function () {
$(this).find(".ck").find("input").attr("checked", "checked");
var a = $(this).find("td").eq(1).text();
$(obj).parent().nextAll().eq(1).find("input").css("display", "inline");
$(obj).parent().nextAll().eq(2).find("input").css("display", "inline");
$(obj).parent().nextAll().eq(3).find("input").css("display", "inline");
$(obj).parent().nextAll().eq(4).find("input").css("display", "inline");
$(obj).parent().nextAll().eq(5).find("input").css("display", "inline"); var trItem = "<tr align='center' id='line" + (parseInt(num) + 1) + "'><td><input id='gvItem_ck_" + (parseInt(num) + 1) + "' type='checkbox' class='ck' onclick='ShowEdit(this);'/></td>"
+ "<td><span id='gvItem_lbNO_" + (parseInt(num) + 1) + "' class='lbNO'>" + (parseInt(a) + 1) + "</span></td>"
+ "<td><input type='text' maxlength='50' id='gvItem_tbPN_" + (parseInt(num) + 1) + "' style='width:80%;display: none' class='tbPN'/></td>"
+ "<td><input type='text' maxlength='50' id='gvItem_tbSN_" + (parseInt(num) + 1) + "' style='width:80%;display: none' class='tbSN'/></td>"
+ "<td><input type='text' maxlength='3' id='gvItem_tbQty_" + (parseInt(num) + 1) + "' style='width:80%;display: none' class='tbQty' onkeyup='GetQty()'/></td>"
+ "<td><input type='text' maxlength='30' id='gvItem_tbSRNo_" + (parseInt(num) + 1) + "' style='width:80%;display: none' class='tbSRNo'/></td>"
+ "<td><input type='text' maxlength='30' id='gvItem_tbSRLineNo_" + (parseInt(num) + 1) + "' style='width:80%;display: none' class='tbSRLineNo' onkeyup='GetSRLineNo()'/></td></tr>";
$("#line" + num).after(trItem);
});
} else {//取消checkbox
var trNode = $(obj).parent().parent();
$($(obj).parent().parent().nextAll("tr")).each(function () {
var a = $(this).find("span").eq(0).text();
$(this).find("span").eq(0).text(a - 1);
});
trNode.remove();
}
}

最新文章

  1. 在 CentOS7 上安装 Tomcat9
  2. markdown命令语法
  3. Visual Studio Code中文文档(一)-快速入门
  4. SQL Server 集合处理
  5. Xcode Alcatraz插件管理介绍和使用
  6. Using the EventManager
  7. android正在运行进程和后台缓存进程的区别
  8. Context是什么,怎么用
  9. mongodb清洗数据
  10. 【HDU】I love sneakers!(分组背包)
  11. JS给元素循环添加事件的问题
  12. Cloud Foundry中warden的网络设计实现——iptable规则配置
  13. C++ 头文件系列(map)
  14. struts2中action的class属性值意义
  15. linux上部署JMeter
  16. Linux 的基本操作(系统用户及用户组的管理)
  17. 基于UML的文献管理系统建模研究
  18. Python基础(下)
  19. 记一次RAID阵列的迁移经历
  20. [py]flask蓝图的使用

热门文章

  1. Arcengine获得arcgis安装的版本
  2. arcgis python获得字段唯一值
  3. Flutter移动电商实战 --(6)dio基础_Get_Post请求和动态组件协作
  4. springboot properties
  5. Pattern Evaluation
  6. umask 介绍
  7. syslog+rsyslog+logstash+elasticsearch+kibana搭建日志收集
  8. 你应该知道的 MySQL 的锁
  9. nova创建虚拟机的详细过程
  10. MongoDB Input