- 浏览: 135109 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
cl1154781231:
谢谢,总算找到一个有用的!
plsql:导入excel数据(手动快速方式) -
RonQi:
很好很强大 今天MyEclipse6.5提示我还有一个月注册码 ...
MyEclipse 6.5 注册机源码 -
tanlingcau:
lixiansky 写道 你上面的写错啦!!!!从网上抄也得试 ...
tomcat在windows下开机自动运行 -
lixiansky:
你上面的写错啦!!!!从网上抄也得试试吧!!!!郁闷.... ...
tomcat在windows下开机自动运行 -
gadflyyy:
标题错了,是导入excel
plsql:导入excel数据(手动快速方式)
页面
servlet
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>grid.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3" /> <meta http-equiv="description" content="this is my page" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" media="screen" href="css/themes/redmond/jquery-ui-1.8.2.custom.css" /> <link rel="stylesheet" type="text/css" media="screen" href="css/themes/ui.jqgrid.css" /> <link rel="stylesheet" type="text/css" media="screen" href="css/themes/ui.multiselect.css" /> <link rel="stylesheet" type="text/css" media="screen" href="css/themes/jquery.searchFilter.css" /> <style> html,body { --margin: 0; /* Remove body margin/padding */ padding: 0; overflow: hidden; /* Remove scroll bars on browser window */ font-size: 75%; } </style> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script> <script src="js/src/ui.multiselect.js" type="text/javascript"></script> <script src="js/src/grid.loader.js" type="text/javascript"></script> <script type="text/javascript"> $.jgrid.no_legacy_api = true; $.jgrid.useJSON = true; </script> <script type="text/javascript"> $(function(){ $("#grid_id").jqGrid({ url:'/demo2/servlet/JqGridJsonServlet', mtype: 'GET', datatype: 'json', jsonReader : { repeatitems: false }, height: "auto", loadui: "disable", colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'], colModel :[ {name:'invId', index:'invId', width:70}, {name:'invDate', index:'invDate', width:120, editable:true}, {name:'amount', index:'amount', width:90, align:'right', editable:true}, {name:'tax', index:'tax', width:90, align:'right', editable:true}, {name:'total', index:'total', width:90, align:'right', editable:true}, {name:'note', index:'note', width:180, sortable:false, editable:true} ], pager: '#pager', rowNum:10, rowList:[10,20,30], sortname: 'invid', sortorder: 'asc', viewrecords: true, caption: 'My first grid' }); }); </script> </head> <body> <table id="grid_id"></table> <div id="pager"></div> </body> </html>
servlet
package com.qoma.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import com.et.ar.exception.ActiveRecordException; import com.qoma.db.vo.InvHeader; import com.qoma.service.InvHeaderService; import com.qoma.util.Json; public class JqGridJsonServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1676458940650461673L; private InvHeaderService service = new InvHeaderService(); /** * Constructor of the object. */ public JqGridJsonServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to * post. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String oper = request.getParameter("oper"); String s = ""; if (null == oper || "".equals(oper)) { Integer page = Integer.parseInt(request.getParameter("page")); Integer limit = Integer.parseInt(request.getParameter("rows")); String sidx = request.getParameter("sidx"); String sord = request.getParameter("sord"); if (null == sidx || "".equals(sidx)) sidx = "1"; Long count = 0L; try { count = service.getCount(); } catch (ActiveRecordException e) { e.printStackTrace(); } Integer totalPages = 0; if (count > 0 && limit > 0) { totalPages = new Long(count / limit).intValue(); if (count % limit != 0) { totalPages += 1; } } else { totalPages = 0; } // if for some reasons the requested page is greater than the total // set the requested page to total page if (page > totalPages) page = totalPages; // calculate the starting position of the rows Integer start = limit * page - limit; if (start < 0) start = 0; try { List<InvHeader> list = service.getLimitList(start, limit, sidx, sord); s = service.getAllJson(page, totalPages, count, list); } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.FAILURE; } } else { String idValue = request.getParameter("id"); Integer invId = (StringUtils.isEmpty(idValue) || "_empty".equals(idValue)) ? 0 : Integer.parseInt(idValue);// add操作时,id值默认为_empty InvHeader vo = new InvHeader(); vo.invId = invId; if ("del".equals(oper)) { try { service.deleteInvHeader(vo); s = Json.SUCCESS; } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.getFailure(e.getMessage()); } } else { String invDateValue = request.getParameter("invDate"); String clientIdValue = request.getParameter("client_Id"); String amountValue = request.getParameter("amount"); String taxValue = request.getParameter("tax"); String totalValue = request.getParameter("total"); String noteValue = request.getParameter("note"); vo.invDate = invDateValue; vo.client_Id = StringUtils.isEmpty(clientIdValue) ? 0 : Integer.parseInt(clientIdValue); vo.amount = StringUtils.isEmpty(amountValue) ? 0 : Float.parseFloat(amountValue); vo.tax = StringUtils.isEmpty(taxValue) ? 0 : Float.parseFloat(taxValue); vo.total = StringUtils.isEmpty(totalValue) ? 0 : Float.parseFloat(totalValue); vo.note = noteValue; if ("add".equals(oper)) { try { if (service.addInvHeader(vo)) { s = Json.SUCCESS; } else { s = Json.FAILURE; } } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.getFailure(e.getMessage()); } } else if ("edit".equals(oper)) { try { if (service.updateInvHeader(vo)) { s = Json.SUCCESS; } else { s = Json.FAILURE; } } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.getFailure(e.getMessage()); } } } } out.println(s); out.flush(); out.close(); } /** * Initialization of the servlet. <br> * * @throws ServletException * if an error occurs */ public void init() throws ServletException { // Put your code here } }
发表评论
-
select box的操作
2011-07-28 16:49 734<select multiple="mul ... -
利用js对象去除数组重复
2011-07-27 14:01 787http://www.iteye.com/topic/7452 ... -
Javascript Returns Zero For parseInt('08') and parseInt('09')
2011-04-21 10:10 790八进制的问题 改为parseInt(<my text v ... -
jqGrid:六、 search
2010-10-09 15:27 2390页面 <!DOCTYPE html PUBLIC &qu ... -
jqGrid:五、 Form Editing
2010-10-09 11:03 1773<!DOCTYPE html PUBLIC " ... -
jqGrid:三、 remote data(XML)
2010-09-30 15:00 1389新建页面jqgrid_xml.html <!DOCTYP ... -
jqGrid:二、 第一个jqGrid
2010-09-30 14:31 1302<!DOCTYPE html PUBLIC " ... -
jqGrid:一、 环境搭建
2010-09-30 14:24 2481jqGrid 3.8 官网http://www.trirand ... -
jqGrid问题
2010-09-30 13:53 9621.页面字体样式显示不正常; 将文档声明为: <!DOC ... -
鼠标形状样式
2010-09-10 11:26 803style="cursor:default" ... -
禁用IE缓存
2010-08-18 10:37 1458有三种方法: 一、在HTML页面中加入META标记: ... -
Javascript中的命名规范
2010-07-28 17:13 866借鉴http://www.w3school.com.cn/js ... -
工作笔记:JsonStore无法正常加载
2010-07-27 18:31 916错误最后查出来是因为store的root没有写正确。因为项目的 ... -
工作笔记:ExtjsGrid数据拖拽页面无法加载
2010-07-27 18:29 774页面按正常思路写的,但出不来。 和别人的页面对比了一下,发现G ... -
Ext.form timeout参数
2010-07-22 17:20 1264Extjs版本2.0 问题:Ext.form的timeout设 ... -
Extjs 开发环境下store不加载数据
2010-07-21 09:41 670表现为在IE下数据显示正常,在FF下数据不显示,查看后台发现并 ... -
检测浏览器是否支持JavaScript功能
2010-05-11 11:20 915<html xmlns="http:// ... -
页面Size
2010-04-22 11:30 687var getPageSize = function () ... -
Ext tbar的多行显示
2010-04-20 13:24 2791var tbar2 = new Ext.Toolbar({ ... -
在IE中使用Extjs出现“拒绝访问”
2010-03-10 18:34 3373关于在IE中使用Extjs出现“拒绝访问”的问题: IE安全 ...
相关推荐
NULL 博文链接:https://tanlingcau.iteye.com/blog/779622
Jqgrid json 自身带的分页功能, 为了减轻数据库压力和提高加载速度,生成了纯JSON文件,想在本地自动分页,找了N多API均没有详细的介绍,最终摸索出来一个属性本身就自带分页功能,与大家分享
现在把找好的分页参数跟大家分享下
jqGrid jQuery网格插件jqGrid是启用AjaxJavaScript控件,它提供用于表示和处理Web上表格数据的解决方案。 由于网格是客户端解决方案,可以通过Ajax回调动态加载数据,因此可以将其与任何服务器端技术集成,包括PHP,...
jqGrid 是一个支持 Ajax 的 JavaScript 控件,它提供了在 Web 上表示和操作表格数据的解决方案。 由于网格是通过 Ajax 回调动态加载数据的客户端解决方案,因此它可以与任何服务器端技术集成,包括 PHP、ASP、Java ...
网格 这是学习 jqgrid 的演示项目在此我创建名为 branch1 的分支
jqGrid 学习 配置 json 35 jqGrid 学习 方法 37 jqGrid 学习 事件 45 jqGrid 学习 数据 48 jqGrid 学习 ColModel API 55 jqGrid 学习 参数(2) 57 jqGrid 学习 jqGrid 参数 63 jqGrid 学习 第一个实例 63 使用 ...
Lib.AspNetCore.Mvc.JqGrid 一组库,它们支持和ASP.NET Core中的使用。 这是从jqGrid的相关功能ASP.NET核心演进 。 Lib.AspNetCore.Mvc.JqGrid.Infrastructure-表示jqGrid选项的类,枚举和常量。 由所有库共享。 Lib...
jqgrid 导出成为 JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG,PDF格式
看到很多网上对含特殊字符 json 数据处理,都是逐个判断是哪个特殊字符,比如回车如何处理,引号如何处理。其实有现成的代码库可以做这件事情,下载 json-lib-2.3-jdk15.jar : 代码如下: import ...
一个jqGrid例子 使用datatype: "local",JSON数据写在页面中时分页、搜索一切正常。 但使用datatype: getProducts, 时点击搜索、排序时数据每次拷贝了一份,(即:原数据有10条,操作后就成20条。。。。)。
; charset=utf-8"> <title>Insert title here ...<link type="text/css" rel="stylesheet" href="css/ui.jqgrid.css"> <script type="text/javascript" src="js/jquery-1.11.0.min.js" ></script> ...
jqgrid 使用: 数据加载 增加, 修改, 删除, 还原, 撤销等 逻辑上都做了很好的判断,希望能给你们带来帮助,以后也会持续更新jqgrid使用代码。
* jsonReader:设置表格的 JSON 读取器。 * loadonce:设置表格的加载一次功能。 * multiboxonly:设置表格的多选框功能。 * multiselect:设置表格的多选功能。 * pager:设置表格的分页器。 * prmNames:设置表格...
基于jquery 实现的优秀grid组件,功能强大,使用上比flexigrid简单,包括完整的使用手册,新版支持json
NULL 博文链接:https://johnson-gong.iteye.com/blog/1921058
jquery.jqGrid-4.6.0(jquery表格插件).zip----------jqGrid4.6.0包,官网下载的,原封不动的在这里。 jqgrid_demo40-----可用的-使用方法请查看README文件.rar-----------经我修改过的demo40,官网上面demo40下载...
link rel="stylesheet" type="text/css" media="screen" href="jqgrid/ui.jqgridffe4.css" /> <style> html, body { margin: 0; padding: 0; font-size: 75%; } </style> [removed]...