jquery-easyui中表格的行编辑功能
datagrid现在具有行编辑能力了,使用时只须在columns中为需要编辑的列添加一个editor属性,编辑保存时同时具有数据校验能力。
看一个例子效果图:

代码如下:
- $('#tt').datagrid({
- title:'Editable DataGrid',
- iconCls:'icon-edit',
- width:660,
- height:250,
- singleSelect:true,
- idField:'itemid',
- url:'datagrid_data.json',
- columns:[[
- {field:'itemid',title:'Item ID',width:60},
- {field:'productid',title:'Product',width:100,
- formatter:function(value){
- for(var i=0; i<products.length; i++){
- if (products[i].productid == value) return products[i].name;
- }
- return value;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'productid',
- textField:'name',
- data:products,
- required:true
- }
- }
- },
- {field:'listprice',title:'List Price',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}},
- {field:'unitcost',title:'Unit Cost',width:80,align:'right',editor:'numberbox'},
- {field:'attr1',title:'Attribute',width:150,editor:'text'},
- {field:'status',title:'Status',width:50,align:'center',
- editor:{
- type:'checkbox',
- options:{
- on: 'P',
- off: ''
- }
- }
- },
- {field:'action',title:'Action',width:70,align:'center',
- formatter:function(value,row,index){
- if (row.editing){
- var s = '<a href="#" onclick="saverow('+index+')">Save</a> ';
- var c = '<a href="#" onclick="cancelrow('+index+')">Cancel</a>';
- return s+c;
- } else {
- var e = '<a href="#" onclick="editrow('+index+')">Edit</a> ';
- var d = '<a href="#" onclick="deleterow('+index+')">Delete</a>';
- return e+d;
- }
- }
- }
- ]],
- onBeforeEdit:function(index,row){
- row.editing = true;
- $('#tt').datagrid('refreshRow', index);
- },
- onAfterEdit:function(index,row){
- row.editing = false;
- $('#tt').datagrid('refreshRow', index);
- },
- onCancelEdit:function(index,row){
- row.editing = false;
- $('#tt').datagrid('refreshRow', index);
- }
- });
原文及下载地址:http://jquery-easyui.wikidot.com/tutorial:datagrid12
jquery-easyui中表格的行编辑功能的更多相关文章
- jquery-easyui 中表格的行编辑功能
具体实现代码如下: <table id="tt"></table> $('#tt').datagrid({ title:'Editable DataGrid ...
- EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件
有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = ...
- JQuery Easyui/TopJUI表格基本的删除功能(删除当前行和多选删除)
需求:数据表格datagrid实现删除当前行和多选删除的功能. html <a href="javascript:void(0)" data-toggle="top ...
- (原创)EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件
有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = ...
- 雷林鹏分享:jQuery EasyUI 数据网格 - 启用行内编辑
jQuery EasyUI 数据网格 - 启用行内编辑 可编辑的功能是最近添加到数据网格(datagrid)的.它可以使用户添加一个新行到数据网格(datagrid).用户也可以更新一个或多个行. 本 ...
- 给Jquery easyui 的datagrid 每行增加操作链接(转)
http://www.thinkphp.cn/code/207.html 通过formatter方法给Jquery easyui 的datagrid 每行增加操作链接我们都知道Jquery的EasyU ...
- Jquery EasyUI中treegrid
Jquery EasyUI中treegrid的中右键菜单和一般按钮同时绑定事件时的怪异事件 InChatter系统开源聊天模块前奏曲 最近在研究WCF,又因为工作中的项目需要,要为现有的系统增加一 ...
- jquery easyUI中combobox的使用总结
jquery easyUI中combobox的使用总结 一.如何让jquery-easyui的combobox像select那样不可编辑?为combobox添加editable属性 设置为false ...
- 求助关于jquery easyUI中的treegrid组件,请各位帮忙给个思路,谢谢啦
现在项目中用到jquery easyUI中的treegrid组件,已经可以正常显示了.但是在保存的时候遇到问题,页面上参照官网的例子可以在页面更新,但是怎么获取编辑后的数据进而保存到数据库呢?
随机推荐
- 查询某个表或者所有表的字段说明 SQLServer
查询某个表或者所有表的字段说明SELECT [Table Name] = OBJECT_NAME(c.object_id), [Column Name] = c.name, [Des ...
- Object-C 基础笔记3---属性
一,区别属性和实例变量 实例变量就是声明在接口大括号里面的变量.@public类型的实例变量直接使用->访问, property 属性是一组设置器和访问器,属性是方法不是变量. 与类相似,属性需 ...
- 14、C#基础整理(函数)
函数 1.概念:是一个带有输入参数.输出参数.返回值的代码块. 2.写法: 修饰符 返回值类型 函数名(输入参数,输入参数) { 方法段 return 返回值; } 3.注释: (1)输入参数格式 ...
- Inno打包教程_百度经验
Inno打包教程 Inno工具,是比较常用的打包软件.简简单单,一招叫你学会使用inno打包. 工具/原料 inno setup 软件 方法/步骤 双击桌面的:Inno setup compiler图 ...
- Jquery autocomplete插件的使用
简单用法: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEnc ...
- php计算一天的时间
代码如下: $time=time(); //一天的开始 $start=strtotime(date('Y-m-d',$time).'00:00:01'); echo date('Y-m-d H:i:s ...
- 项目乱码 GBK转UTF-8工具
项目乱码 GBK转UTF-8工具 链接:http://pan.baidu.com/s/1pLw1mMB 密码:rj6c
- python数据结构与算法——小猫钓鱼(使用队列)
按照<啊哈>里的思路实现这道题目,但是和结果不一样,我自己用一幅牌试了一下,发现是我的结果像一点,可能我理解的有偏差. # 小猫钓鱼 # 计算桌上每种牌的数量 # 使用defaultdic ...
- Linux中“新旧”TCP/IP工具的对比
如今很多系统管理员依然通过组合使用诸如ifconfig.route.arp和netstat等命令行工具(统称为net-tools)来配置网络功能.解决网络故障,net-tools起源于BSD的TCP/ ...
- linux 中 chmod/chown/cngrp的用法与区别
1.chgrp(转变文件所属用户组) chgrp 用户组 文件名 .若是整个目次下的都改,则加-R参数用于递归. 如:chgrp -R user smb.conf 2.chown(转变文件拥有者) ...