使用EasyUI的Datagrid的Editor进行行编辑,Enter回车结束编辑,并开启新的一行。
//新增数据
function add() {
if (Index == undefined) {
row = { move_date: '', start_time: '', end_time: '', start_place: '', arrival_place: '', move_vehicle: '' };
$('#dg').datagrid('appendRow', row);
Index = $('#dg').datagrid('getRows').length - 1;
$('#dg').datagrid('selectRow', Index).datagrid('beginEdit', Index);
}//新建行结束
//回车时结束编辑,并开启新一行放在datagrid的onBeginEdit事件里
onBeginEdit: function (Index, row) {
var stayPlace = $("#dg_StaySchedule").datagrid('getEditor', { index: Index, field: 'stay_place' });
var stayAmount = $("#dg_StaySchedule").datagrid('getEditor', { index: Index, field: 'stay_amount' });
$(stayPlace.target).textbox('options').onChange = function (newValue, lodValue) {
//开启等待
MaskUtil.mask();
$.ajax({//根据条件值获取数据
type: "POST",
url: "url?stay_place=" + newValue + "&emp_title=" + $('#emp_title').textbox('getValue'),
dataType: 'json',
success: function (msg) {
//关闭等待
MaskUtil.unmask();
stayData = 0;
stayData = JSON.parse(msg.stay);
$(stayAmount.target).textbox('setValue', stayData);//查询的数据给列赋值
}
})
}
//回车时结束编辑,并开启新一行
$('.datagrid-editable .textbox,.datagrid-editable .datagrid-editable-input,.datagrid-editable .textbox-text').bind('keypress', function (e) {
var code = e.keyCode || e.which;
f (code == 13) {
//保存更改 第一次编辑可能不会改变值
var b = $('#dg').datagrid('validateRow', Index);
if (b == false) {
$('#dg').datagrid('selectRow', Index).datagrid('beginEdit', Index);
return;
}
$('#dg').datagrid('acceptChanges');
$('#dg').datagrid('endEdit', Index);
if (stayData > 0 && row.stay_amount > stayData) {
$.messager.confirm('操作提示', "提交的住宿费已超标准费用,标准住宿费用是:" + stayData + "元,是否继续?", function (r) {
if (r) {
$('#dg').datagrid('unselectRow', Index);
Index= undefined;
add();//新增方法
}
else {
$('#dg').datagrid('beginEdit', Index);
}
})
} else {
Index= undefined;
add();//新增方法
}
}
});
}
使用EasyUI的Datagrid的Editor进行行编辑,Enter回车结束编辑,并开启新的一行。的更多相关文章
- Easyui的datagrid的editor(行编辑器)如何扩展datetimebox类型
在easyui的datagrid扩展方法中添加这样的时间日期(datetimebox)代码块 放在 $.extend($.fn.datagrid.defaults.editors,{datetim ...
- Easyui 设置datagrid 进入编辑状态,保存结束编辑
在datagrid中如何实现让一行进入编辑状态,修改数据后,保存信息呢? //点击列表变成文本框,进入可编辑状态 $(function () { var doc = $(document), tabl ...
- 学习日记6、easyui datagrid 新增一行,编辑行,结束编辑和删除行操作记录
1.新增一行并进入编辑状态 var index=$('#Numbers').datagrid('appendRow', { CardInformation: '开户行', CardNumber: '银 ...
- [转]jQuery EasyUI自定义DataGrid的Editor
原文地址:http://www.jeasyuicn.com/post-3.html 官网datagrid的api:http://jquery-easyui.wikidot.com/document:d ...
- easyui datagrid的editor编辑器如何为validatebox控件添加改变事件
项目中需要为行编辑器Editor的某个列的文本框添加改变事件 需求:新增行时,为用户名输入特殊字符进行验证,不允许保存用户数据 html页面 <table id="gridlist&q ...
- easyUI的datagrid控件日期列不能正确显示Json格式数据的解决方案
EasyUI是一套比较轻巧易用的Jquery控件,在使用过程中遇到一个问题,它的列表控件——datagrid, 在显示日期列的时候,由于后台返回给页面的数据是Json格式的,其中的日期字段,在后台是正 ...
- easyUI中datagrid的使用
easyUI中的datagrid数据表格经常被用到,结合项目中的使用情况,总结一下datagrid使用中需要注意的一些问题.使用datagrid展示数据,需要在html.css.js中都要编写代码,h ...
- easyui,datagrid表格,行内可编辑
最近用到easyui,需要表格内编辑,但是我同一个页面有多个表格,把官方的代码修改了一下,如下: HTML代码 <table id="dg" class="easy ...
- EasyUI效果--DataGrid的编辑效果
DataGrid的编辑效果是我目前使用的easyUI的第三个效果,相对于前两个,这个算是比较复杂点了. 运行起来的效果,大概就是这样,任意点击某行,然后该行变为可以编辑的,失去焦点之后,该行恢复 ...
随机推荐
- xfs 的一些工具使用
[root@localhost caq]# xfs_db -c frag -r /dev/sdaw actual , ideal , fragmentation factor 82.56% Note, ...
- vue-cli脚手架中webpack配置基础文件详解
一.前言 原文:https://segmentfault.com/a/1190000014804826 vue-cli是构建vue单页应用的脚手架,输入一串指定的命令行从而自动生成vue.js+wep ...
- MFC新建工程中目录包含中文,资源文件打开失败
※尽量不适用中文,各种未知错误,嘿嘿 此方法临时解决问题,可以使程序运行,后续是否还有错误是未知数 需要修改3处位置: 1.资源文件中.rc 右键,点击“查看代码”,找到带中文的资源ID,把中文修改掉 ...
- C++指针和字符串
]="rose'; cout<<flowers<<endl; 数组名是第一个元素的地址,
- “AS3.0高级动画编程”学习:第一章高级碰撞检测
AdvancED ActionScript 3.0 Animation 是Keith Peters大师继"Make Things Move"之后的又一力作,网上已经有中文翻译版本了 ...
- pl/sql developer 问题总结
问题1,出现NLS_LANG和字符集(Character set)问题 安装完PL/SQL后打开,遇到如图问题. 原因:这是因为系统没有设置NLS_LANG系统变量. 解决方法:有两种方式查看. 1. ...
- python测试开发django-2.templates模板与html页
前言 Django 中的视图的概念是一类具有相同功能和模板的网页的集合.通俗一点来说,就是你平常打开浏览器,看到浏览器窗口展示出来的页面内容,那就是视图.前面一章通过浏览器访问http://127.0 ...
- FOB注意事项
1. FOB是我们作为贸易公司去联系物流公司将货送到码头,缴纳FOB cost 以后,海关安排码头的人送到船上. 2.在这之前,买方自己订船,然后发给卖方入货通知,卖方安排发货. 3.FOB cost ...
- 第七周博客作业 <西北师范大学| 周安伟>
第七周博客作业 助教博客链接:https://home.cnblogs.com/u/zaw-315/ 本周无评作业 查看了同学们提交的对实验四的附加实验项目互评.其中对博文结构,内容来评价是否符合作业 ...
- 报错:The import android.support cannot be resolved
下一个android-support-v7-appcompat.jar 然后导入即可 :