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("内存分配失败! ...
随机推荐
- new date() 函数在浏览器中的兼容问题!!
引言: 同一种语言javascript,在不同的浏览器中,存在语言兼容性问题,本质上是由于不同的浏览器是支持的语言标准和实现上各有差异.本文将基于new Date来创建Date对象来分析这个问题. v ...
- 返回 m 到 n 的随机整数
返回 m 到 n 的随机整数 <script type="text/javascript"> function randomNumber(m,n){ return Ma ...
- C# 配置文件读取与修改(转)
C# 配置文件读取与修改 配置文件在很多情况下都使用到, 配置文件分为两种 一种是应用程序的配置文件, 一种是web的配置文件. 两种配置文件最大的区别是web的配置文件更新之后会实时更新, 应用 ...
- javascript 正则匹配手机号码
<form class="form-horizontal" name="mobileform" style="padding:10px;&q ...
- po 和 mo 的互相转换
反编译 mo 文件成 po 文件 msgunfmt test.mo -o test.po 编码 po 文件为 mo 文件 msgfmt -o test.mo test.po 记着备用.
- eclipse中JSP开发环境的配置
1. Java环境 自行百度配置 2. Web Server环境安装: Web Server选择流行的Apache Tomcat .到http://tomcat.apache.org/ 处下载, ...
- Linux下如何发布Qt程序
在X11平台下qt程序,首先准备好程序中需要使用的资源,库和插件... 比如你的可运行程序取名叫作panel,那把你的panel,那些libQt*.so.4和libQt*.so.4.6.0(链接 ...
- Smarty for foreach 使用
{for} {for}{forelse}用于创建一个简单的循环. 下面的几种方式都是支持的: {for $var=$start to $end}步长1的简单循环. {for $var=$start t ...
- 在QLabel上点击获得的效果
一般说只在button中点击获得事件,作出相应的反应.而往往需要在QLabel上作出点击和触碰的效果. 我用qlabel做出了一个效果,当鼠标碰到label区域,label底下出现一条线,离开后线条消 ...
- 2014-08-13 SQL语句之Left Join
今天是在吾索实习的第26天.这天在处理数据库数据的时候发现了一个不错的语句就是Left Join,即左连接. 其功能是:即使右表中没有匹配,也从左表返回所有的行.也就是说,显示的行数与左表一致,且当 ...