easyui datagrid编辑
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Datagrid.aspx.cs" Inherits="EasyUI.Datagrid" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
#div1
{ border:1px solid red;
width:300px;
height:500px;
position:absolute;
left:620px;
top:50px;
}
</style>
<link href="../themes/icon.css" rel="stylesheet" />
<link href="../themes/default/easyui.css" rel="stylesheet" />
<link href="../src/demo.css" rel="stylesheet" />
<script src="../comjs/jquery-1.8.0.min.js" type="text/javascript"></script>--%>
<script src="src/easyloader.js" type="text/javascript"></script>
<script src="../comjs/jquery.easyui.min.js" type="text/javascript"></script>
<script>
var users = {
total: 6, rows: [
{ no: 1, name: '用户1', addr: '山东济南', email: 'user1@163.com', birthday: '1/1/1980' },
{ no: 2, name: '用户2', addr: '山东济南', email: 'user2@163.com', birthday: '1/1/1980' },
{ no: 3, name: '用户3', addr: '山东济南', email: 'user3@163.com', birthday: '1/1/1980' },
{ no: 4, name: '用户4', addr: '山东济南', email: 'user4@163.com', birthday: '1/1/1980' },
{ no: 5, name: '用户5', addr: '山东济南', email: 'user5@163.com', birthday: '1/1/1980' },
{ no: 6, name: '用户6', addr: '山东济南', email: 'user6@163.com', birthday: '1/1/1980' }
]
};
$(function () {
$('#tt').datagrid({
title: 'Editable DataGrid',
iconCls: 'icon-edit',
width: 530,
height: 250,
singleSelect: true,
columns: [[
{ field: 'no', title: '编号', width: 50, editor: 'numberbox' },
{ field: 'name', title: '名称', width: 60, editor: 'text' },
{ field: 'addr', title: '地址', width: 100, editor: 'text' },
{
field: 'email', title: '电子邮件', width: 100,
editor: {
type: 'validatebox',
options: {
validType: 'email'
}
}
},
{ field: 'birthday', title: '生日', width: 80, editor: 'datebox' },
{
field: 'action', title: '操作', width: 70, align: 'center',
formatter: function (value, row, index) {
if (row.editing) {
var s = '<a href="#" onclick="saverow(' + index + ')">保存</a> ';
var c = '<a href="#" onclick="cancelrow(' + index + ')">取消</a>';
return s + c;
} else {
var e = '<a href="#" onclick="editrow(' + index + ')">编辑</a> ';
var d = '<a href="#" onclick="deleterow(' + index + ')">删除</a>';
return e + d;
}
}
}
]],
toolbar: [{
text: '增加',
iconCls: 'icon-add',
handler: addrow
}, {
text: '保存',
iconCls: 'icon-save',
handler: saveall
}, {
text: '取消',
iconCls: 'icon-cancel',
handler: cancelall
}],
onBeforeEdit: function (index, row) {
row.editing = true;
$('#tt').datagrid('refreshRow', index);
editcount++;
},
onAfterEdit: function (index, row) {
row.editing = false;
$('#tt').datagrid('refreshRow', index);
editcount--;
},
onCancelEdit: function (index, row) {
row.editing = false;
$('#tt').datagrid('refreshRow', index);
editcount--;
}
}).datagrid('loadData', users).datagrid('acceptChanges');
});
var editcount = 0;
function editrow(index) {
$('#tt').datagrid('beginEdit', index);
}
function deleterow(index) {
$.messager.confirm('确认', '是否真的删除?', function (r) {
if (r) {
$('#tt').datagrid('deleteRow', index);
}
});
}
function saverow(index) {
$('#tt').datagrid('endEdit', index);
}
function cancelrow(index) {
$('#tt').datagrid('cancelEdit', index);
}
function addrow() {
if (editcount > 0) {
$.messager.alert('警告', '当前还有' + editcount + '记录正在编辑,不能增加记录。');
return;
}
$('#tt').datagrid('appendRow', {
no: '',
name: '',
addr: '',
email: '',
birthday: ''
});
}
function saveall() {
$('#tt').datagrid('acceptChanges');
}
function cancelall() {
$('#tt').datagrid('rejectChanges');
}
</script>
</head>
<body>
<h1>Editable DataGrid</h1>
<table id="tt"></table>
</body>
</html>
easyui datagrid编辑的更多相关文章
- 扩展jquery easyui datagrid编辑单元格
扩展jquery easyui datagrid编辑单元格 1.随便聊聊 这段时间由于工作上的业务需求,对jquery easyui比较感兴趣,根据比较浅薄的js知识,对jquery easyui中的 ...
- easyui datagrid 编辑模式详解
一,建立编辑器 从api得知,扩展一种新的编辑器类型,需要提供以上几个方法.项目中正好需要一个checkbox 类型编辑器,但在easyui中并没提供这样的编辑器,那我们可以通过扩展编辑器来解决 ...
- jquery easyui datagrid 编辑行 类型combobox
完成编辑瞬间datagrid中显示的是combobox的value 而非text var rows=$('#tb1').datagrid('getRows'); for(var i=0;i<ro ...
- EasyUI DataGrid 编辑单元格
如下图: 现改为单击某个单元格只对此单元格进行可编辑 <TABLE>标记添加 onClickCell <table id="dg" class="eas ...
- easyui datagrid编辑时编辑框自动获取焦点
onDblClickCell:function(rowIndex, field, val){//双击单元格监听器 $(this).datagrid('beginEdit',rowIndex);//开启 ...
- EasyUI DataGrid编辑单元格时使用combogrid
仅提供一段columns配置代码供参考: conditions对象是一个已赋值的数组对象集合.下拉框数据可直接使用conditions数据,也可以通过url获取. columns : [[ { fie ...
- easyui datagrid的列编辑
[第十五篇]easyui datagrid的列编辑,同时插入两张表的数据进去 看图说话. 需求:插入两张表,上面的表单是第一张表的内容,下面的两个表格是第二张详情表的内容,跟第一张表的id关联 第 ...
- EasyUI Datagrid 自定义列、Foolter及单元格编辑
1:自定义列,包括 Group var head1Array = []; head1Array.push({ field: 'Id', title: 'xxxx', rowspan: 2 }); he ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
前言 有时候我们的后台系统表单比较复杂,做过进销存或者一些销售订单的都应该有过感觉 虽然Easyui Datagrid提供了行内编辑,但是不够灵活,但是我们稍微修改一下来达到批量编辑,批量删除,批量添 ...
随机推荐
- 收集的一些python基础教学博客
=======python3学习链接======= Python 3 教程:http://www.runoob.com/python3/python3-tutorial.html 深入python3: ...
- Dark theme for Texstudio - TeX - LaTeX
Dark theme for Texstudio ~~~ 1.window系统如下操作 ~~~ 1. texstudio的配置文件texstudio 的配置文件在~/.config/texstudi ...
- 查windows系统开关机记录
https://blog.csdn.net/dufufd/article/details/53316079 者是按下"开始菜单"-"程序"-"管理工具 ...
- 门禁系统socket通讯编程
最近遇到一个socke udp协议通讯的需求,而且是16进制数据接收.这样在传输参数的时候老是提示参数错误,因为计算机是不能直接传输16进制的,会自行转换,所有以下代码非常完美的解决我的问题,同时也让 ...
- 17 网络编程 C/S架构介绍
1.什么是C/S架构 C指的是client(客户端软件),S指的是Server(服务器软件),本章的重点是教大家写一个C/S架构的软件,实现服务端软件与客户端软件基于网络通信. 2.计算机基础的知识- ...
- 关闭IPV6
[root@bgw-t ~]# cat > /etc/modprobe.d/ipv6.conf << EOF alias net-pf-10 off options ipv6 dis ...
- SQL Server:查看数据库用户权限(SQL 2005)
1. 查看 SQL 2005 用户所属数据库角色 use yourdb go select DbRole = g.name, MemberName = u.name, MemberSID = u.si ...
- Zabbix安装(server和agent)及基本配置
简介 zabbix([`zæbiks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制 ...
- css3自定义placeholder字体颜色
::-webkit-input-placeholder{color:#f00;} ::-moz-placeholder{color:#f00;} :-moz-placeholder{color:#f0 ...
- hdoj1160 DP--LIS
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1160 思路: 又是一道LIS的应用题,先预处理,按照w从小到大排列,那么原问题就转变成求该排列的LIS ...