EasyUI 启用行内编辑
创建数据网格(DataGrid)
- $(function(){
- $('#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(this)">Save</a> ';
- var c = '<a href="#" onclick="cancelrow(this)">Cancel</a>';
- return s+c;
- } else {
- var e = '<a href="#" onclick="editrow(this)">Edit</a> ';
- var d = '<a href="#" onclick="deleterow(this)">Delete</a>';
- return e+d;
- }
- }
- }
- ]],
- onBeforeEdit:function(index,row){
- row.editing = true;
- updateActions(index);
- },
- onAfterEdit:function(index,row){
- row.editing = false;
- updateActions(index);
- },
- onCancelEdit:function(index,row){
- row.editing = false;
- updateActions(index);
- }
- });
- });
- function updateActions(index){
- $('#tt').datagrid('updateRow',{
- index: index,
- row:{}
- });
- }
为了启用数据网格行内编辑,您应该添加一个 editor 属性到列中。编辑器(editor)会告诉数据网格(datagrid)如何编辑字段及如何保存字段值。正如您所看到的,我们定义的三个编辑器(editor):text、combobox 和 checkbox。
- function getRowIndex(target){
- var tr = $(target).closest('tr.datagrid-row');
- return parseInt(tr.attr('datagrid-row-index'));
- }
- function editrow(target){
- $('#tt').datagrid('beginEdit', getRowIndex(target));
- }
- function deleterow(target){
- $.messager.confirm('Confirm','Are you sure?',function(r){
- if (r){
- $('#tt').datagrid('deleteRow', getRowIndex(target));
- }
- });
- }
- function saverow(target){
- $('#tt').datagrid('endEdit', getRowIndex(target));
- }
- function cancelrow(target){
- $('#tt').datagrid('cancelEdit', getRowIndex(target));
- }
EasyUI 启用行内编辑的更多相关文章
- 雷林鹏分享:jQuery EasyUI 数据网格 - 启用行内编辑
jQuery EasyUI 数据网格 - 启用行内编辑 可编辑的功能是最近添加到数据网格(datagrid)的.它可以使用户添加一个新行到数据网格(datagrid).用户也可以更新一个或多个行. 本 ...
- jQuery EasyUI 数据网格 - 启用行内编辑(转自http://www.runoob.com/jeasyui/jeasyui-datagrid-datagrid12.html)
可编辑的功能是最近添加到数据网格(datagrid)的.它可以使用户添加一个新行到数据网格(datagrid).用户也可以更新一个或多个行.本教程向您展示如何创建一个数据网格(datagrid)和内联 ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(83)-Easyui Datagrid 行内编辑扩展
这次我们要从复杂的交互入手来说明一些用法,这才能让系统做出更加复杂的业务,上一节讲述了Datagird的批量编辑和提交本节主要演示扩展Datagrid行内编辑的属性,下面来看一个例子,我开启编辑行的时 ...
- 第一节:EasyUI样式,行内编辑,基础知识
一丶常用属性 $('#j_dg_left').datagrid({ url: '/Stu_Areas/Stu/GradeList', fit: true, // 自动适应父容器大小 singleSel ...
- easyui datagrid行内编辑
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- Easyui datagrid行内【添加】、【编辑】、【上移】、【下移】
前几天项目中遇到一个需求用到了Easyui datagrd行内添加和编辑数据,同时对行内数据上移下移,所以对这几个功能做个总结. 1.首先大概说下这几个功能里用到的主要方法,行内添加数据主要是添加列的 ...
- ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑
前言: 为了赶进度,周末也写文了! 前几篇讲完查询框和工具栏,这节讲表格数据相关的操作. 先看一下列表: 接下来我们有很多事情可以做. 1:格式化 - 键值的翻译 对于“启用”列,已经配置了格式化 # ...
- js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable
js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable 一.总结 一句话总结:bootstrap能够做为最火的框架,绝对不仅仅只有我看到的位置,它应该还有很多位置可 ...
- JS组件系列——BootstrapTable 行内编辑解决方案:x-editable
前言:之前介绍bootstrapTable组件的时候有提到它的行内编辑功能,只不过为了展示功能,将此一笔带过了,罪过罪过!最近项目里面还是打算将行内编辑用起来,于是再次研究了下x-editable组件 ...
随机推荐
- UVA1422-Processor(二分法+优先队列)
option=com_onlinejudge&Itemid=8&category=512&page=show_problem&problem=4168"> ...
- 用算法求N(N>=3)之内素数的个数
首先.我们谈一下素数的定义.什么是素数?除了1和它本身外,不能被其它自然数整除(除0以外)的数 称之为素数(质数):否则称为合数. 依据素数的定义,在解决问题上,一開始我想到的方法是从3到N之间每一个 ...
- kubernetes容器编排之定义环境变量以及通过downwardapi把pod信息作为环境变量传入容器内
系列目录 在学习docker的时候,大家可能经常看到不少示例在docker run的时候指定环境变量(比如wordpress的docker示例就是通过环境变量传入账户和密码到容器内).这里之所以经常用 ...
- 备忘:js正则表达式中的元字符
Predefined term Matches \t Horizontal tab \b Backspace \v Vertical tab \f Form feed \r Carriage retu ...
- MySQL 导入导出命令(转载)
导出数据: mysqldump --databases -u root -p密码 数据库名> /root/guogl/XXX.sql 从sql文件导入数据: mysql -u root -p密码 ...
- C++ 中的几种初始化
前言 阅读C++教材时,想必你听过复制初始化,直接初始化,值初始化这三个概念吧.笔者本人常将其混淆,遂在此记录下它们的具体含义以便日后查阅. 复制初始化( copy-initialization ) ...
- EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要自定义认证
本文转自EasyDarwin开源团队成员的博客:http://blog.csdn.net/ss00_2012/article/details/52330838 在前面<EasyDarwin拉流支 ...
- [Phoenix] 一、快速入门
Phoenix是一个开源的HBASE SQL层.Phoeinx可以用标准的JDBC API替代HBASE client API来创建表,插入和查询HBASE中的数据. Phoenix作为应用层和HBA ...
- LeastRecentlyUsed
LeastRecentlyUsed Operating Systems http://www.cs.jhu.edu/~yairamir/cs418/os6/sld001.htm Cache repla ...
- lazy evaluation and deferring a computation await promise async
Promise - JavaScript | MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ ...