当前位置:网站首页>点击table的td单元格出现dialog弹窗,获取值后将值放回td单元格
点击table的td单元格出现dialog弹窗,获取值后将值放回td单元格
2022-06-30 12:50:00 【全栈程序员站长】
用dialog做个弹窗,做了一天一夜终于在各种百度下一点一点试出来了。
$("#table1 td").on('click',function () {
<!--获取所点击单元格td的id-->
var eachTdId=$(this).attr("id");
<!--此为难点,下面一步可以根据所点击的id与已存在的列id比较,可为table中的哪几列执行弹窗事件,-->
if(eachTdId=="tdoriCodeBk" || eachTdId=="tdoriCodeBk2" || eachTdId=="tdoriCodeBk3"){
<!--获取所点击单元格的列数-->
var tdSeq = $(this).parent().find("td").index($(this));
<!--获取所点击单元格的行数-->
var trSeq = $(this).parent().parent().find("tr").index($(this).parent());
<!--dialog插件-->
var d = dialog({
title: '备用元数据添加',
<!--跳出的弹窗链接到控制器-->
url: '${base}/cis/cisDataItemDef/itemDefList',
<!--关闭弹出后执行的function函数-->
onclose:function(){
<!--难点,将子界面传来的值放回到所点击的单元格input框中,在tr:eq("+trSeq+") 比较是,必须用+号才能将var类型装成数字比较-->
$("#table1 tr:eq("+trSeq+") td:eq("+tdSeq+") input").val($("#hide").val()); }}); d.height(450) d.width(750) d.showModal();
}
});
控制器代码
@RequestMapping("/itemDefList")
public String itemDefList(){
return "/cis/cisDataItemDef/cisDataItemDefList.ftl";
}
控制器转到ftl页面,出现弹窗内容的jquery代码
<script>
$("#save").on("click",function(){
<!--获取所点击行的内容-->
var rows = $('#table').bootstrapTable('getSelections');
var code = [];
for(var i=0;i<rows.length;i++){
code.push(rows[i]['oriCode']);
}
if(code.length==0){
alert("请选择要添加的元素");
return false;
}
window.returnvalue=rows;
$("aa").value=rows;
var d = ar_.getDialog(parent);/* parent.dialog.get(window); */
<!--将处理的值放到父页面的一个隐藏域中-->
$(window.parent.$("#hide").val(code));
<!--关闭弹窗-->
d.close();
}
});发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106388.html原文链接:https://javaforall.cn
边栏推荐
- How to take the first step in digital transformation
- get请求与post提交区别的简易理解
- Multi terminal collaboration of Huawei accounts to create a better internet life
- Database usage in QT
- 发生QQ大规模盗号事件,暴露出什么网络安全问题?
- 幸运哈希竞猜系统开发(源码部署)趣投哈希游戏玩法开发(案例需求)
- 今日睡眠质量记录80分
- Basic syntax of unity script (5) - vector
- Resource realization applet opening traffic main tutorial
- Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
猜你喜欢

Dark horse notes - common date API

Multi terminal collaboration of Huawei accounts to create a better internet life

60 个神级 VS Code 插件!!

【精选】资源变现资讯、新闻、自媒体、博客小程序(可引流,开通流量主,带pc后台管理)

Unity Animator 参数

防火墙基础之总部双机热备与分支基础配置

Open source of xinzhibao applet

Postman génère automatiquement des fragments de code Curl

商品服务-平台属性

Goods and services - platform properties
随机推荐
MySQL queries the data within the radius according to the longitude and latitude, and draws a circle to query the database
mqtt-ros模拟发布一个自定义消息类型
【C】深入理解指针、回调函数(介绍模拟qsort)
DeFi“钱从哪来”?一个大多数人都没搞清楚的问题
Resource realization applet opening wechat official small store tutorial
Illustration creating a stored procedure using Navicat for MySQL
How can I protect my private key?
Unity脚本的基础语法(5)-向量
Clearing TinyMCE rich text cache in elementui
写信宝小程序开源
Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
独立站即web3.0,国家“十四五“规划要求企业建数字化网站!
ABAP toolbox v1.0 (with implementation ideas)
mysql拒绝访问、管理员身份打开的
Basic syntax of unity script (5) - vector
幸运哈希竞猜系统开发(源码部署)趣投哈希游戏玩法开发(案例需求)
JS 二维数组变一维数组的方法
[kali] Kali system, software update (with image source)
Tronapi wave field interface PHP version - interface document attached - package based on thinkphp5 - source code without encryption - can be opened in two - detailed guidance of the author - 11:49:56
Apache Doris Compaction優化百科全書