- 浏览: 135588 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 : { id: "invId",//the unique id of the row.如果不设置则默认为行号. repeatitems: false //element tells jqGrid that the information for the data in the row is repeatable - i.e. the elements have the same tag cell described in cell element. Setting this option to false instructs jqGrid to search elements in the json data by name. This is the name from colModel or the name described with the jsonmap option in colModel. //A very useful feature here is that there is no need to include all the data that is represented in colModel. Since we make a search by name, the order does not need to match the order in colModel. //设置为false,则可以在json串中根据列/值为传数据,并且列/值在json串中的位置可以随意,也可以不传。 }, height: "auto", loadui: "disable", colNames:['Inv No','Date', 'ClientId', 'Amount','Tax','Total','Notes'], colModel :[ {name:'invId', index:'invId', width:70, search:false}, //name:Set the unique name in the grid for the column. This property is required. As well as other words used as property/event names, the reserved words (which cannot be used for names) include subgrid, cb and rn. //index:Set the index name when sorting. Passed as sidx parameter.index是后台排序时使用。 //search:Determines if the field can be searched.是否可以作为搜索条件 {name:'invDate', index:'invDate', width:120, editable:true, search:false}, {name:'client_Id', index:'client_Id', 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, search:false} ], pager: '#pager', rowNum:10, rowList:[10,20,30], sortname: 'invid', sortorder: 'asc', viewrecords: true, caption: 'My first grid' }); //jQuery("#grid_id").jqGrid('navGrid','#pager',{parameters},prmEdit, prmAdd, prmDel, prmSearch, prmView) jQuery("#grid_id").jqGrid('navGrid','#pager',{add:true,edit:true,view:true,del:true,search:true,refresh:true}, {url:'/demo2/servlet/JqGridJsonServlet',closeAfterEdit:true, closeOnEscape:true, left:240}, // settings for edit {url:'/demo2/servlet/JqGridJsonServlet',closeAfterAdd:true, closeOnEscape:true, left:240}, // settings for add {url:'/demo2/servlet/JqGridJsonServlet',closeAfterEdit:true, closeOnEscape:true, top:90, left:240, resize:false, drag:false}, // settings for del {url:'/demo2/servlet/JqGridJsonServlet',multipleSearch:true, closeAfterSearch:true, closeOnEscape:true, sopt:['le','ge']}, // enable the advanced searching {closeOnEscape:true, left:240} // allow the view dialog to be closed when user press ESC key ); }); </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(); private InvHeader vo; private String search;// 是否为搜索 private String filters;// 搜索值 private String searchField; private String searchOper; private String searchString; private Integer page;// 当前页 private Integer rows;// 每页记录数 private String sidx;// 排序列 private String sord;// 排序为正序倒序 private String oper;// 数据操作 private String s;// 返回值 private Long count;// 总记录数 private Integer totalPages;// 总页数 private Integer start;// 开始位置 /** * 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(); this.initParameter(request); if ("true".equals(search)) {// 搜索 if (StringUtils.isEmpty(filters)) {// 单条件搜索 this.pageCount(); try { List<InvHeader> list = service.getLimitList(start, rows, sidx, sord, searchField, searchString, searchOper); s = service.getAllJson(page, totalPages, count, list); } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.FAILURE; } } else {// 多重搜索 //filters = {"groupOp":"AND","rules":[{"field":"client_Id","op":"eq","data":"2"},{"field":"tax","op":"ne","data":"4"}]} } } else { if (StringUtils.isEmpty(oper)) {// 查询操作 this.pageCount(); try { List<InvHeader> list = service.getLimitList(start, rows, sidx, sord); s = service.getAllJson(page, totalPages, count, list); } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.FAILURE; } } else {// 增删改操作 if ("del".equals(oper)) { try { service.deleteInvHeader(vo); s = Json.SUCCESS; } catch (ActiveRecordException e) { e.printStackTrace(); s = Json.getFailure(e.getMessage()); } } else { 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 } private void initParameter(HttpServletRequest request) { search = request.getParameter("_search"); filters = request.getParameter("filters"); searchField = request.getParameter("searchField"); searchOper = request.getParameter("searchOper"); searchString = request.getParameter("searchString"); oper = request.getParameter("oper"); String pageValue = request.getParameter("page"); page = StringUtils.isEmpty(pageValue) ? 0 : Integer.parseInt(pageValue); String rowsValue = request.getParameter("rows"); rows = StringUtils.isEmpty(rowsValue) ? 0 : Integer.parseInt(rowsValue); sidx = request.getParameter("sidx"); sord = request.getParameter("sord"); String idValue = request.getParameter("id"); Integer invId = (StringUtils.isEmpty(idValue) || "_empty".equals(idValue)) ? 0 : Integer.parseInt(idValue);// add操作时,id值默认为_empty 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 = new InvHeader(); vo.invId = invId; 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; } private void pageCount() { if (StringUtils.isEmpty(searchField) || StringUtils.isEmpty(searchString) || StringUtils.isEmpty(searchOper)) { try { count = service.getCount(); } catch (ActiveRecordException e) { e.printStackTrace(); } } else { try { count = service.getCount(searchField, searchString, searchOper); } catch (ActiveRecordException e) { e.printStackTrace(); } } if (null == sidx || "".equals(sidx)) sidx = "1"; if (count > 0 && rows > 0) { totalPages = new Long(count / rows).intValue(); if (count % rows != 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 start = rows * page - rows; if (start < 0) start = 0; } }
- demo2_src.zip (9.9 KB)
- 下载次数: 55
发表评论
-
select box的操作
2011-07-28 16:49 743<select multiple="mul ... -
利用js对象去除数组重复
2011-07-27 14:01 790http://www.iteye.com/topic/7452 ... -
Javascript Returns Zero For parseInt('08') and parseInt('09')
2011-04-21 10:10 797八进制的问题 改为parseInt(<my text v ... -
jqGrid:五、 Form Editing
2010-10-09 11:03 1777<!DOCTYPE html PUBLIC " ... -
jqGrid:四、 remote data(JSON)
2010-10-09 10:33 1786页面 <!DOCTYPE html PUBLIC &qu ... -
jqGrid:三、 remote data(XML)
2010-09-30 15:00 1392新建页面jqgrid_xml.html <!DOCTYP ... -
jqGrid:二、 第一个jqGrid
2010-09-30 14:31 1314<!DOCTYPE html PUBLIC " ... -
jqGrid:一、 环境搭建
2010-09-30 14:24 2486jqGrid 3.8 官网http://www.trirand ... -
jqGrid问题
2010-09-30 13:53 9711.页面字体样式显示不正常; 将文档声明为: <!DOC ... -
鼠标形状样式
2010-09-10 11:26 811style="cursor:default" ... -
禁用IE缓存
2010-08-18 10:37 1460有三种方法: 一、在HTML页面中加入META标记: ... -
Javascript中的命名规范
2010-07-28 17:13 869借鉴http://www.w3school.com.cn/js ... -
工作笔记:JsonStore无法正常加载
2010-07-27 18:31 917错误最后查出来是因为store的root没有写正确。因为项目的 ... -
工作笔记:ExtjsGrid数据拖拽页面无法加载
2010-07-27 18:29 777页面按正常思路写的,但出不来。 和别人的页面对比了一下,发现G ... -
Ext.form timeout参数
2010-07-22 17:20 1266Extjs版本2.0 问题:Ext.form的timeout设 ... -
Extjs 开发环境下store不加载数据
2010-07-21 09:41 672表现为在IE下数据显示正常,在FF下数据不显示,查看后台发现并 ... -
检测浏览器是否支持JavaScript功能
2010-05-11 11:20 920<html xmlns="http:// ... -
页面Size
2010-04-22 11:30 692var getPageSize = function () ... -
Ext tbar的多行显示
2010-04-20 13:24 2796var tbar2 = new Ext.Toolbar({ ... -
在IE中使用Extjs出现“拒绝访问”
2010-03-10 18:34 3378关于在IE中使用Extjs出现“拒绝访问”的问题: IE安全 ...
相关推荐
直接从官方网站上下载...2 如果遇到Toolbar上 search按钮 放大镜图标 出现布局错误 遮罩把所有内容都遮住了 此时可以尝试将demo文件夹中的 themes目录下的 ui jqgrid css 文件 替换为源码包中的版本 或者替换成 http: ...
jqGrid 按多个条件 或单个条件进行查询
jqGrid 4.4.1 New search module, Tree Grid and SubGrid improvements, new colModel cellattr event and much more... Enjoy
此为课程范例网站,利用一个快速打造的Web 介绍Microsoft Azure WebApp 的功能,以及如何利用Microsoft Azure Search 服务建立高水准的搜寻功能。 资料来源 政府资料开放平台提供的登革热近12个月每日确定病例统计 ...
jqGrid本身带有search和edit表格模块,但是这些模块会使得整个插件体积显得有点庞大,而且笔者认为jqGrid的搜索查询和编辑/添加功能不好用,所以笔者放弃jqGrid自有的search和edit表格模块,借助jquery利器来完成...
我这里用的不是jqGrid的自带的编辑和删除操作,我已经把分页导航栏下的编辑,删除,搜索都取消掉了,就是这句$(“#list1”).navGrid(“#pager1”,{edit:false,del:false, search:false}), 然后在数据加载完成后,给每...
前台模块中bootstrap-paginator分页插件,sweetalert、jqGrid、toastr。 后端: SpringBoot做基础框架、SpringSecurity做授权与认证、Mybaties做数据访问层控制,全文检索使用Elasticsearch、数据库使用MySQL。 ...
springboot + mybatis + bootstrap + jqgrid + ajax + elasticsearch(用到在整合) + redis(用到在整合) 项目编码: UTF-8 项目名称: poem 数据库名称: poem 项目中包结构: src/main/java com.baizh.xxx ...
后端主要技术:Spring 4.1.5(管理事务)、Spring MVC 4.1.5(作为控制层)、Spring Security 4.0.0(认证和授权,权限管理)、Hibernate 4.3.8(作为数据持久层)、MyBatis 3.2.8(作为数据持久层)、Hibernate Search 5.1.0...
Search results Tables with details FAQ page (now available) User profile (now available) Inline editable data (now available) File upload and management Email template (now available) Inbox & messages...
$("#searchForm").serialize(); 但是,观察输出的信息,发现serialize()方法做的是将表单中的数据以htpp请求格式拼接成字符串。 serialize确实是能够解决一般的提交数据。但是有时我们需要的是一个object对象,而...
JavaScript, they can't be easily bookmarked by users, and search engines don't always know how to parse them. Also, not everyone likes AJAX. While some are developing enterprise architectures using ...
├── search_result.html(搜索结果) ├── skin-config.html(主题设置选项) ├── social_feed.html(信息流) ├── spinners.html(加载动画) ├── suggest.html(搜索建议) ├── sweetalert...