datagrid的基本操作-增删改
1 ---恢复内容开始--- <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/jquery-easyui-1.4.2/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/jquery-easyui-1.4.2/themes/icon.css">
<!--<link rel="stylesheet" type="text/css" href="../../图片/demo.css">-->
<script type="text/javascript" src="__PUBLIC__/jquery-easyui-1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
</head>
<body>
<h2>Basic DataGrid</h2>
<p>The DataGrid is created from markup, no JavaScript code needed.</p> <div style="margin:20px 0;"></div> <table id="tb" class="easyui-datagrid" toolbar="#toolbar" title="Basic DataGrid" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,collapsible:true,url:'{:U(return_json)}',method:'get'"> <thead> <tr>
<th data-options="field:'Item_ID',width:80">Item ID</th>
<th data-options="field:'Product',width:100">Product</th>
<th data-options="field:'List_Price',width:80,align:'right'">List Price</th>
<th data-options="field:'Unit_Cost',width:80,align:'right'">Unit Cost</th>
<th data-options="field:'Attribute',width:250">Attribute</th>
<th data-options="field:'Status',width:60,align:'center'">Status </th>
</tr>
</thead>
</table> <div id="toolbar">
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true"onclick="newUser()">添加</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="true"onclick="editUser()">修改</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-save" plain="true"onclick="saveUser()">保存</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="true"onclick="destroyUser()">删除</a> </div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="">User Information</div>
<form id="fm" method="post" novalidate> <div class="fitem">
<label>Product:</label>
<input name="Product" class="easyui-textbox" type="text" required>
</div>
<div class="fitem">
<label>List Price:</label>
<input name="List_Price" type="text" class="easyui-textbox">
</div>
<div class="fitem">
<label>Unit Cost:</label>
<input name="Unit_Cost" type="text" class="easyui-textbox">
</div>
<div class="fitem">
<label>Attribute:</label>
<input name="Attribute" type="text" class="easyui-textbox" >
</div>
<div class="fitem">
<label>Status:</label>
<input name="Status" type="text" class="easyui-textbox">
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
</div> <script type="text/javascript">
var url;
//当创建用户时,打开一个对话框并清空表单数据。
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','New User');//打开对话框
$('#fm').form('clear');//清空表单数据 url = '__URL__/insert';
}
//当编辑用户时,打开一个对话框并从 datagrid 选择的行中加载表单数据。
function editUser(){
var row = $('#tb').datagrid('getSelected');//获取选中的行
if (row){
$('#dlg').dialog('open').dialog('setTitle','Edit User');
$('#fm').form('load',row);
url = '__URL__/update?id='+row.Item_ID;//获取tb表的主键,传给后台数据库
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
console.log(result);
if (result.errorMsg){
$.messager.show({
title: 'Error',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#tb').datagrid('reload'); // reload the user data
}
}
});
}
function destroyUser(){
var row = $('#tb').datagrid('getSelected');
if (row){
$.messager.confirm('Confirm','Are you sure you want to destroy this user?',function(r){
if (r){
$.post('__URL__/del',{id:row.Item_ID},function(result){
if (result==1){ $('#tb').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: 'Error',
msg: result.errorMsg
});
}
},'json');
}
});
}
}
</script>
</body>
</html> ---恢复内容结束---
datagrid的基本操作-增删改的更多相关文章
- MongoDB的ObjectId和基本操作增删改查(3)
ObjectId 基本操作增删改查 增: insert 介绍: mongodb存储的是文档,. 文档是json格式的对象. 语法: db.collectionName.insert(document) ...
- MongoDB --- 02. 基本操作,增删改查,数据类型,比较符,高级用法,pymongo
一.基本操作 . mongod 启动服务端 2. mongo 启动客户端 3. show databses 查看本地磁盘的数据库 4. use 库名 切换到要使用的数据库 5. db 查看当前使用的数 ...
- web sql 基本操作 - 增删改查
不喜欢看md原文的 可以访问这个链接:http://note.youdao.com/noteshare?id=6a91e3dea7cdf5195bb0e851d9fcb5a5 # web sql 增删 ...
- Windows 10 64位操作系统 下安装、连接测试sqlite3 sql基本操作 增删改
一.下载sqlite安装包 1:详细下载安装版本可见官网:https://www.sqlite.org/download.html 2:百度盘分享连接:https://pan.baidu.com/s/ ...
- MongoDB基本操作(增删改查)
基本操作 基本的“增删查改“,在DOS环境下输入mongo命令打开shell,其实这个shell就是mongodb的客户端,同时也是一个js的编译器,默认连接的是“test”数据库.
- mangodb的基本操作:增删改差
MongoDB三元素: 1 数据库: 和关系型数据库中数据库的层次相同,内部可以有多个集合. 2 集合: 相当于关系型数据库中的表,存储若干文档,结构不固定 3 文档: 相当于关系型数据库中的行,是J ...
- django数据库基本操作-增删改查(tip)-基本
补充:django外键保存 #外键保存 form_data = Form_Data() project, is_created = Project_Name.objects.get_or_create ...
- MySQL语句基本操作增删改查
select * from 表名; --------->效率低
- c语言实现双链表的基本操作—增删改查
//初始化 Node*InitList() { Node*head=(Node*)malloc(sizeof(Node)); if(NULL==head) { printf("内存分配失败! ...
随机推荐
- Javascript的location对象
JavaScript window.location对象 示例 注意 方法 经常使用window.location,它的结构总是记不住,简单梳理下,方便以后查询. 示例 URL:http://b.a. ...
- phpEXCEL操作全解
phpExcel中文帮助手册,列举了各种属性,以及常用的操作方法,难得是每一个都用实例加以说明,希望对大家有所帮助. phpExcel中文帮助手册,不可多得的好文章,供大家学习参考. 1.设置exce ...
- iOS常见异常Exec_Bad_Access问题解决办法
iOS常见异常Exec_Bad_Access问题解决办法 在iOS开发中,经常遇到Exec_Bad_Access异常,导致程序奔溃问题,一般这个问题都是因为过早的release对象,然后又对该 ...
- pin导致路由器死掉的解决方法
首先检测网卡: ifconfig -a 然后模拟端口: airmon-ng start wlan0 接下来用: airodump-ng mon0 扫描ap找到你pin死的路由器mac 用mdk3 做身 ...
- Linux准备——安装Ubuntu系统
今天对于我这个试图向安装Linux方向走的童鞋来说是个值得纪念的日子——我成功的安装上了Ubuntu操作系统. 整个的过程并不复杂,主要是看了网上Linux社区的一个安装教程.开始,我还在XP下安装, ...
- webserver and application server
http://www.diffen.com/difference/Application_Server_vs_Web_Server http://www.differencebetween.com/d ...
- COJ 0359 xjr考考你数据结构(根号2)线段树区间增加
xjr考考你数据结构(根号2) 难度级别:C: 运行时间限制:3000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 请你编写一个数据结构,完成以下功能: 1)求出第 ...
- COJ 0036 数数happy有多少个?
数数happy有多少个? 难度级别:B: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 图图是个爱动脑子.观察能力很强的好学生.近期他正学英语 ...
- BZOJ3392: [Usaco2005 Feb]Part Acquisition 交易
3392: [Usaco2005 Feb]Part Acquisition 交易 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 26 Solved: ...
- 设计模式 ( 二十一 ):Vistor访问者模式 -- 行为型
1.概述 在软件开发过程中,对于系统中的某些对象,它们存储在同一个集合collection中,且具有不同的类型,而且对于该集合中的对象,可以接受一类称为访问者的对象来访问,而且不同的访问者其访问方式有 ...