当前位置:网站首页>easyui修改以及datagrid dialog form控件使用
easyui修改以及datagrid dialog form控件使用
2022-07-25 16:23:00 【迟早嘚秃】

前言:今天学习的是三个控件
dialog控件:弹窗
基本方法:
oppen打开
close关闭
属性
closed:true
(更多可自行前往api查看)
form控件:表单
submit 提交表单
url:提交路径
sucess方法接收后台数据
load:将数据回写给表单
detagrid:数据表格
getSelected 获取表格一行数据
formatter表格列属性
reload刷新数据表格
这就是今天我们要讲的所有控件以及方法,上面是这些方法对应的用法
今天目标实现数据表格中的修改
首先我们给表格新增一列操作列将修改加入
$('#dg')
.datagrid(
{
url : $("#ctx").val() + '/book.action?methodName=books',
pagination : true,
fitColumns : true,
checkbox : true,
toolbar : '#tb',
columns : [ [
{
field : 'bid',
title : 'id',
width : 100
},
{
field : 'bname',
title : '名称',
width : 100
},
{
field : 'price',
title : '价格',
width : 100
},
{
field : '操作',
title : '操作',
width : 100,
align : "right",
formatter : function(value, row, index) {
return "<a href='javascript:void(0);' οnclick='xg()'>修改</a>"
}
}
] ]
})
看不懂得可以参照前面几次课的博客
第二部,点击修改弹出弹出框给修改一个点击事件
然后在弹出框中加入一个表单用来提交
将选中修改的数据回写到表单中去
最后提交到后台进行数据库修改,
在关闭弹出框,刷新表格数据
jsp页面弹窗以及表单代码
<div id="dd" class="easyui-dialog" title="编辑窗体"
style="width: 500px; height: 200px;"
data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true,buttons:'#bb'">
<!-- 提交的from表单 -->
<form id="ff" action="" method="post">
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="bname" style="width:100%" data-options="label:'书名:',required:true">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="price" style="width:100%"
data-options="label:'价格:',required:true">
</div>
<input type="hidden" id="book_id" name="bid" value="">
</form>
<div style="text-align:center;padding:5px 0">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">Submit</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">Clear</a>
</div>
</div>
修改点击事件
function xg() {
//获取选中行数据
var row = $('#dg').datagrid('getSelected');
//打开弹窗
$('#dd').dialog('open');
//将数据给表单
$('#ff').form('load', row);
}
表单提交
$('#ff').form('submit', {
//路径
url: $("#ctx").val() + '/book.action?methodName=bookxg',
success: function(data){
//接收后台的值判断是否修改成功
if(data==1){
$('#dd').dialog('close')
$('#dg').datagrid('reload')
}
}
});
后端
(如果不懂建议看之前博客自定义mvc框架)
先写dao方法
public void bookxg(Book b) throws Exception {
super.executeUpdate("update t_mvc_book set bname=? ,price=? where bid=? ", b,
new String[] {
"bname", "price", "bid" });
}
再写子控制器调用dao方法
public String bookxg(HttpServletRequest req, HttpServletResponse resp) {
try {
bookdao.bookxg(book);
ResponseUtil.writem(resp, 1);
} catch (Exception e) {
// TODO Auto-generated catch block
try {
ResponseUtil.writem(resp, 0);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
e.printStackTrace();
}
return null;
}
运行结果
边栏推荐
- leetcode:6127. 优质数对的数目【位运算找规律 + 两数之和大于等于k + 二分】
- Gap locks
- 用递归进行数组求和
- Record locks
- MyBaits
- Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]
- Today, I went to oppo for an interview and was asked numbly
- 百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
- Implementation of recommendation system collaborative filtering in spark
- PageHelper.startPage没有生效问题
猜你喜欢

使用Huggingface在矩池云快速加载预训练模型和数据集

Breakthrough in core technology of the large humanoid Service Robot Walker x

百度富文本编辑器UEditor单张图片上传跨域

Equivalent change of resistance circuit (Ⅱ)

Exploration of 6-wire SPI transmission mode

测试驱动开发(TDD)在线练功房 | 9月17日开课
![[JS advanced] JS regular correlation functions and regular objects_ 02](/img/a0/27bf3f5146a5774eb3167a69d1e3cf.png)
[JS advanced] JS regular correlation functions and regular objects_ 02

Test Driven Development (TDD) online practice room | classes open on September 17

进程之间的通信(管道详解)

IaaS基础架构云 —— 云网络
随机推荐
Exclusive lock
Shared lock
What is a physical firewall? What's the effect?
What is the shortcut key for win11 Desktop Switching? Win11 fast desktop switching method
终极套娃 2.0 | 云原生交付的封装
百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)
2W word detailed data Lake: concept, characteristics, architecture and cases
Implementation of recommendation system collaborative filtering in spark
How does win11's own drawing software display the ruler?
Record locks
Equivalent change of resistance circuit (Ⅱ)
Permission management - role assignment menu
Simple rotation map and hamster beating
mysql 查看是否锁表
C# 音乐
MySQL intent lock
可验证随机函数 VRF
MyBaits
乐观锁悲观锁适用场景