当前位置:网站首页>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:154. 寻找旋转排序数组中的最小值 II【关于旋转排序数组的中后定位二分法】
- linux内核源码分析之页表缓存
- 微信小程序不使用插件,渲染富文本中的视频,图片自适应,plus版本
- 优必选大型仿人服务机器人Walker X的核心技术突破
- TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format
- Visual studio 2022 view class diagram
- 如何安装govendor并打开项目
- 阿唐的小帮手
- 共享锁(Shared Lock)
- 墨天轮高分技术文档分享——数据库安全篇(共48个)
猜你喜欢

What is the shortcut key for win11 Desktop Switching? Win11 fast desktop switching method
![[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code](/img/9e/138e4b160fa9bd6486fac44a788d09.png)
[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code

Equivalent change of resistance circuit (Ⅱ)

解决Win10磁盘占用100%

Paper notes: highly accurate protein structure prediction with alphafold (alphafold 2 & appendix)

城市燃气安全再拉警钟,如何防患于未“燃”?

Talk about how to use redis to realize distributed locks?

今天睡眠质量记录84分
![Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]](/img/03/54a2d82a17cd07374dc0aedacd7b11.png)
Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]

Emqx cloud update: more parameters are added to log analysis, which makes monitoring, operation and maintenance easier
随机推荐
MySQL table read lock
Quickly deploy mqtt clusters on AWS using terraform
Recursive menu query (recursion: check yourself)
Leetcode:528. select randomly according to the weight [ordinary random failure + prefix and dichotomy]
mysql 表读锁
The annualized interest rate of treasury bonds is too low. Is there a financial product with a higher annualized interest rate than the reverse repurchase of treasury bonds?
How to build an enterprise level OLAP data engine for massive data and high real-time requirements?
测试驱动开发(TDD)在线练功房 | 9月17日开课
墨天轮高分技术文档分享——数据库安全篇(共48个)
slf4j 搭配 log4j2 处理日志
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
[JS advanced] JS regular correlation functions and regular objects_ 02
Record Locks(记录锁)
Implementation of recommendation system collaborative filtering in spark
Product upgrade observation station in June
[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
How does win11's own drawing software display the ruler?
Baidu rich text editor ueeditor image width 100% adaptive, mobile terminal
什么是链游系统开发?链游系统开发如何制作
权限管理-删除菜单(递归)