DHTMLX Grid中实现分页查询_第1页
DHTMLX Grid中实现分页查询_第2页
DHTMLX Grid中实现分页查询_第3页
DHTMLX Grid中实现分页查询_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Grid中实现分页查询注:将Tomcat 5.0下的conf/server.xml中的URIEncoding 设置成UTF-8可以解决中文问题1、导入文件:<link rel="STYLESHEET" type="text/css" href="././codebase/dhtmlxgrid.css"><link rel="STYLESHEET" type="text/css" href="././codebase/ext/dhtmlxgrid_pgn_bricks.

2、css"><script src="././codebase/dhtmlxcommon.js"></script><script src="././codebase/dhtmlxgrid.js"></script><script src="././codebase/ext/dhtmlxgrid_pgn.js"></script><script src="././codebase/dhtmlxgridcell.js">

3、</script>2、jsp页中的相关设置/两个input域 和一个button按钮用于模糊查询<div>Name<br><input type="text" id="search_name"></div><div>Chname<br><input type="text" id="search_chname"><button onclick="reloadGrid()" id="sub

4、mitButton" style="margin-left:30px;">Search</button></div><div id="gridbox" style="width:100%;height:200px;margin-top:20px;margin-bottom:10px;"></div><div><span id="pagingArea"></span></div>3、初始化:<scri

5、pt>function doOnLoad()var mygrid = new dhtmlXGridObject('gridbox');mygrid.setImagePath("././codebase/imgs/");mygrid.setHeader("id,name,chname,pwd");mygrid.setInitWidths("150,150,*,150")mygrid.setColAlign("left,left,left,right")mygrid.setColSorting(&

6、quot;server,na,na,server");mygrid.setColTypes("ro,ro,ro,ro");mygrid.setSkin("light");mygrid.init();/mygrid.enablePaging(true,10,5,"pagingArea",true);mygrid.setPagingSkin("bricks");/mygrid.loadXML("./././user!mylist.action");</script>/enabl

7、ePaging中对应的参数的意义分别是:是否开启分页;每页显示的行数(这里设置为10行);每次显示多少页(下图为显示5页);分页div的id;是否显示统计结果(对应下图的 Records from 1 to 10 of 999)/模糊插叙方法function reloadGrid()var name_mask = document.getElementById("search_name").valuevar chname_mask = document.getElementById("search_chname").value/把查询条件传到action

8、中mygrid.clearAndLoad("<%=basePath%>user!mylist.action?name_mask="+name_mask+"&chname_mask="+chname_mask);4、后台action/得到posStart(从那条数据开始读)count(读取多少条数据)和两个查询条件String count = req.getParameter("count");String posStart = req.getParameter("posStart");Strin

9、g name = req.getParameter("name_mask");String chname = req.getParameter("chname_mask");/第一次请求posStart和count值均为空,需要一个默认值int icount=50;/默认第一次取出50条记录try icount =Integer.parseInt(count); catch (Exception e) if(null=count)icount = 50;int iposStart=0;try iposStart = Integer.parseInt(po

10、sStart); catch (Exception e) if(null=posStart)iposStart = 0;/统计数据的总条数(在这里直接得到一个list,然后conntlist.size取得的)对应xml文、/件中的total_count的值List conntlist = baseService.queryByHqlName("queryPage",map);/定义一个Map,将查询条件put到map中Map map = new HashMap();if (name=null) name=""if (chname=null) chname

11、=""map.put("nameP","%"+name+"%");map.put("chnameP","%"+chname+"%");/ 通过调用BaseDaoImpl中类的loadPageData方法进行分页查询,得到一个list/参数"queryPage"为user-query.hbm.xml中的name(就是下面的代码)list = baseService.loadPageData(iposStart,icount,UserFor

12、m.class,"queryPage",map);5、user-query.hbm.xml配置文件<query name="queryPage">from UserForm where 1=1and name like :namePand chname like :chnameP</query>6、xml文件格式 (这个例子用到了数据库中users表)/ total_count为数据总行数;pos为起始行<?xml version="1.0" encoding="UTF-8"?><rows total_count='conntlist.size()' pos='iposStart'

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论