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的基本操作-增删改的更多相关文章

  1. MongoDB的ObjectId和基本操作增删改查(3)

    ObjectId 基本操作增删改查 增: insert 介绍: mongodb存储的是文档,. 文档是json格式的对象. 语法: db.collectionName.insert(document) ...

  2. MongoDB --- 02. 基本操作,增删改查,数据类型,比较符,高级用法,pymongo

    一.基本操作 . mongod 启动服务端 2. mongo 启动客户端 3. show databses 查看本地磁盘的数据库 4. use 库名 切换到要使用的数据库 5. db 查看当前使用的数 ...

  3. web sql 基本操作 - 增删改查

    不喜欢看md原文的 可以访问这个链接:http://note.youdao.com/noteshare?id=6a91e3dea7cdf5195bb0e851d9fcb5a5 # web sql 增删 ...

  4. Windows 10 64位操作系统 下安装、连接测试sqlite3 sql基本操作 增删改

    一.下载sqlite安装包 1:详细下载安装版本可见官网:https://www.sqlite.org/download.html 2:百度盘分享连接:https://pan.baidu.com/s/ ...

  5. MongoDB基本操作(增删改查)

    基本操作      基本的“增删查改“,在DOS环境下输入mongo命令打开shell,其实这个shell就是mongodb的客户端,同时也是一个js的编译器,默认连接的是“test”数据库.  

  6. mangodb的基本操作:增删改差

    MongoDB三元素: 1 数据库: 和关系型数据库中数据库的层次相同,内部可以有多个集合. 2 集合: 相当于关系型数据库中的表,存储若干文档,结构不固定 3 文档: 相当于关系型数据库中的行,是J ...

  7. django数据库基本操作-增删改查(tip)-基本

    补充:django外键保存 #外键保存 form_data = Form_Data() project, is_created = Project_Name.objects.get_or_create ...

  8. MySQL语句基本操作增删改查

    select * from 表名; --------->效率低

  9. c语言实现双链表的基本操作—增删改查

    //初始化 Node*InitList() { Node*head=(Node*)malloc(sizeof(Node)); if(NULL==head) { printf("内存分配失败! ...

随机推荐

  1. [转]Windows中的句柄(handle)

    1.句柄是什么?   在windows中,句柄是和对象一一对应的32位无符号整数值.对象可以映射到唯一的句柄,句柄也可以映射到唯一的对象.2.为什么我们需要句柄?   更准确地说,是windows需要 ...

  2. assert实现

    测试网站在国内国外的访问速度 关于C的右左法则 assert宏的实现(一道笔试题) 2010-11-09 13:05:48|  分类: c |  标签: |举报 |字号大中小 订阅     asser ...

  3. java include包含指令例子

    1.项目架构 2. 代码 (1)top.jsp 2.copyright.jsp 3.index.jsp 4.效果图: 5.总结 期间也碰到过很多问题,例如我刚开始不是创建的java动态项目而是java ...

  4. Entity Framework with MySQL 学习笔记一(关系)

    这一篇说说 EF Fluent API 和 DataAnnotations 参考 : http://msdn.microsoft.com/en-us/data/jj591617.aspx http:/ ...

  5. reg51.h 详解

    /* BYTE Register */ sfr P0 = 0x80; //P0口 sfr P1 = 0x90; //P1口 sfr P2 = 0xA0; //P2口 sfr P3 = 0xB0; // ...

  6. Android AlertDialog全屏显示去除白色边框

    使用styles.xml风格: Style.xml代码 <style name="FullScreenDialog" parent="android:style/T ...

  7. hadoop2.2.0 MapReduce分区

    package com.my.hadoop.mapreduce.partition; import java.util.HashMap;import java.util.Map; import org ...

  8. Spring中Ioc容器的注入方式

    1 通过setter方法注入 bean类: package com.test; public class UserServiceImplement implements IUserService { ...

  9. char和int的转换

    import java.util.Scanner; public class test7 { public static void main(String[] args) { // TODO Auto ...

  10. MYSQL存储过程,清除指前缀的定表名的数据

    MYSQL存储过程,清除指前缀的定表名的数据 DELIMITER $$ DROP PROCEDURE IF EXISTS `drop_table`$$ ),)) BEGIN ) DEFAULT NUL ...