Flexigrid例子二: 原位编辑器
有时候,我们想要编辑flexigrid里的数据。一个原位编辑器是需要的,现在不需要再弹出一个对话框了。这里我会展示如何做到这点。
我使用了jquery-in-place-editor库。请参考官方站点:http://code.google.com/p/jquery-in-place-editor/
step1: 在定义flexigrid模型的时候,添加一个函数来处理flexigrid的列
- $(document).ready ( function() {
- $("#displays").flexigrid (
- {
- url: '<%=jsonp%>/bindedDisplays',
- method:'POST',
- dataType: 'json',
- width: 400,
- height: 300,
- colModel : [
- {hide: '<%=check%>', name: 'check', width: 30, sortable: true, align: 'left'},
- {display: 'ID', name: 'id', width: 90, sortable: true, align: 'left'},
- {display: '<%=description%>', name: 'description', width: 110, sortable: true, align: 'left',process:editDescription},
- {display: '<%=status%>', name: 'status', width: 20, sortable: true, align: 'left'},
- {display: '<%=unbind%>', name: 'unbind', width: 20, sortable: true, align: 'left',process:unbindDisplay}
- ]
- }
- );
- }
- );
$(document).ready ( function() {
$("#displays").flexigrid (
{
url: '<%=jsonp%>/bindedDisplays',
method:'POST',
dataType: 'json',
width: 400,
height: 300,
colModel : [
{hide: '<%=check%>', name: 'check', width: 30, sortable: true, align: 'left'},
{display: 'ID', name: 'id', width: 90, sortable: true, align: 'left'},
{display: '<%=description%>', name: 'description', width: 110, sortable: true, align: 'left',process:editDescription},
{display: '<%=status%>', name: 'status', width: 20, sortable: true, align: 'left'},
{display: '<%=unbind%>', name: 'unbind', width: 20, sortable: true, align: 'left',process:unbindDisplay}
]
}
);
}
);
step2: 使用jquery-in-place-editor来实现editDescription函数
- function editDescription(celDiv, id){
- $( celDiv ).click( function() {
- var idTd = $(celDiv).parent().parent().children()[1];
- $(celDiv).editInPlace({
- url: "update_description",
- params: "address="+$(idTd.children).html(),
- error:function(obj){
- alert(JSON.stringify(obj));
- },
- success:function(obj){
- var str = m[JSON.parse(obj).status+""][window.curLanguage];
- alert(str);
- $("#displays").flexReload();
- }
- });
- });
- }
function editDescription(celDiv, id){
$( celDiv ).click( function() {
var idTd = $(celDiv).parent().parent().children()[1];
$(celDiv).editInPlace({
url: "update_description",
params: "address="+$(idTd.children).html(),
error:function(obj){
alert(JSON.stringify(obj));
},
success:function(obj){
var str = m[JSON.parse(obj).status+""][window.curLanguage];
alert(str);
$("#displays").flexReload();
}
});
});
}
$(celDiv).editInPlace 会让你在web界面上看到原位编辑的效果。
Ajax请求会通过jquery-in-place-editor发到web server的update_description路径上。
非常简单,你当然也需要引入必要的js文件,像这样:
- <script type="text/javascript" src="script/jquery.editinplace.js"></script>
<script type="text/javascript" src="script/jquery.editinplace.js"></script>
原文链接:http://blog.csdn.net/sheismylife/article/details/7908611
Flexigrid例子二: 原位编辑器的更多相关文章
- scrapy-splash抓取动态数据例子二
一.介绍 本例子用scrapy-splash抓取一点资讯网站给定关键字抓取咨询信息. 给定关键字:打通:融合:电视 抓取信息内如下: 1.资讯标题 2.资讯链接 3.资讯时间 4.资讯来源 二.网站信 ...
- Quartz1.8.5例子(二)
/* * Copyright 2005 - 2009 Terracotta, Inc. * * Licensed under the Apache License, Version 2.0 (the ...
- Linux学习笔记之十二————vim编辑器的分屏操作
一.分屏操作: sp: 上下分屏,后可跟文件名 vsp: 左右分屏,后可跟文件名 Ctr+w+w: 在多个窗口切换 二.启动分屏: 1.使用大写O参数进行垂直分屏 $ vim -On file1 fi ...
- Python例子二
例1.构造函数 #-*-coding:utf--*- import sys class Student: def __init__(self,name,age): self.__name=name s ...
- go例子(二) 使用go语言实现数独游戏
例子托管于github example.go package main import ( "./sudoku" ) func main() { //var smap ...
- 从零开始学习Node.js例子二 文本提交与显示
index.js var server = require("./server"); var router = require("./router"); var ...
- C#解析XML 例子二
<checkResult> <item> <fmId>XX0001</fmId> <fmItemId>20000RT</fmItemI ...
- [原][osg][QT]osg与QT界面结合的简单例子二
//main.cpp #include "VREObliqueEditorQTWindow.h" #include <QtWidgets/QApplication> # ...
- Libevent例子(二)
服务端 #include<netinet/in.h> #include<stdio.h> #include<string.h> #include<event. ...
随机推荐
- 初试体验java多线程
现在个人电脑以及服务器都是多核cpu,如何提高多核cpu的利用率,就要用到多线程技术了. public class TestThread1 { ; static class PThread exten ...
- CSS Margin外边距合并
应该知道这点东西的!!! 可是偏偏记不住! 外边距合并会发生在以下两种情况下: 1 垂直出现的两个拥有外边距的块级元素. div1 { margin-bottom: 20px; } div2 { ma ...
- PhoneGap原理分析
PhoneGap提供了Native Api的支持(如:重力感应.相机.联系人.文件.地址位置…), 比如要用js获取本机的联系人,可以用: var options = new ContactFindO ...
- 【jmeter】non-gui模式运行
operty文件,默认是使用JMETER_HOME/bin目录下的jmeter.properties,如果用户自定义有其它的配置,在这里加上 #用法如下: -p user.properties -q, ...
- 解决tableView分割线左边不到边的情况
//解决tableView分割线左边不到边的情况// if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {// ...
- 剑指offer系列43---判断平衡二叉树
[题目]判断一颗二叉树是不是平衡二叉树. * 平衡二叉树定义:任意子节点深度相差不超过1.[思路]由上题,利用递归得到二叉树每个结点的深度同时比较. package com.exe9.offer; i ...
- thinkphp中redirect重定向后隐藏index.php
首先,.htaccess文件要配置好隐藏index.php.系统默认生成的就行. 然后,也是最关键的一部,要在Application/Home/Conf里的config.php文件中增加如下配置: & ...
- Func系列3:自定义模块
简介 Func自带的模块已经非常丰富,但在日常系统运维当中,尤其是面对大规模的服务器集群.不同类别的业务平台,次是Func自带的模块或许已经不能满足我们的需求,所以有必要通过自定义模块来填补这块的不足 ...
- Python 字典和列表的对比应用
Q:将下列格式的txt文件,打印出该选手的3个最快跑步时间 james2.txt =>“James Lee,2002-3-14,2-34,3:21,2.34,2.45,3.01,2:01,2:0 ...
- FastReport使用二——二维码
以下内容在FastReport Designer 中测试通过,如下图所示: 在使用FastReport Designer创建一维吗也就是一般普通的条码时,设置其Barcode属性为Code128 (建 ...