EXT+DWR+SPRING+IBATIS+ORACLE分页显示+模糊查询

 

EXT代码:

 

		Ext.onReady(function(){
			//页条数
			var pageSize=13;			
			// 创建checkbox
				var sm = new Ext.grid.CheckboxSelectionModel({
					// 监听器
					listeners : {
						selectionchange : function(sm) {
							if (sm.getCount()) {
								grid.passButton.enable();
								grid.noPassButton.enable();
							} else {
								grid.passButton.disable();
								grid.noPassButton.disable();
							}
						}
					}
			});
			// 创建列模型	
			var cm = new Ext.grid.ColumnModel([
				sm,
			{
				id:'torder_id',
				header:'电信工单编号',
				dataIndex:'TORDER_ID',
				width:0,
				sortable:true
			},{
				header:'电信工单号',
				dataIndex:'TORDER_CODE',
				width:120,
				sortable:true
			},{
				header:'套餐类型',
				dataIndex:'PACKAGE_TYPE',
				width:120,
				sortable:true
			},{
				header:'金额',
				dataIndex:'MONEY',
				width:120,
				sortable:true
			},{
				header:'开户区号',
				dataIndex:'AREA',
				width:120,
				sortable:true
			},{
				header:'用户名称',
				dataIndex:'CUST_NAME',
				width:120,
				sortable:true
			},{
				header:'用户标致码',
				dataIndex:'USER_FLAG',
				width:120,
				sortable:true
			},{
				header:'E家通套餐识别码',
				dataIndex:'E_USER_FLAG',
				width:120,
				sortable:true
			},{
				header:'性别',
				dataIndex:'SEX',
				width:120,
				sortable:true
			},{
				header:'联系电话',
				dataIndex:'TELEPHONE',
				width:120,
				sortable:true
			},{
				header:'身份证号',
				dataIndex:'IDCARD',
				width:120,
				sortable:true
			},{
				header:'联系地址',
				dataIndex:'ADDRESS',
				width:120,
				sortable:true
			},{
				header:'宽带账号',
				dataIndex:'WIDE_CODE',
				width:120,
				sortable:true
			},{
				header:'宽带绑定电话',
				dataIndex:'WIDE_TELE',
				width:120,
				sortable:true
			},{
				header:'经办人',
				dataIndex:'CREATOR',
				width:120,
				sortable:true
			},{
				header:'创建时间',
				dataIndex:'CREATE_TIME',
				width:120,
				sortable:true
			}]);
			// 生成一个构造器
			var dataRecords = Ext.data.Record.create([
			{
				name:'TORDER_ID',
				type:'long'
			},{
				name:'TORDER_CODE',
				type:'String'
			},{
				name:'PACKAGE_TYPE',
				type:'String'
			},{
				name:'MONEY',
				type:'String'
			},{
				name:'AREA',
				type:'String'
			},{
				name:'CUST_NAME',
				type:'String'
			},{
				name:'USER_FLAG',
				type:'String'
			},{
				name:'SEX',
				type:'String'
			},{
				name:'TELEPHONE',
				type:'String'
			},{
				name:'IDCARD',
				type:'String'
			},{
				name:'ADDRESS',
				type:'String'
			},{
				name:'WIDE_CODE',
				type:'String'
			},{
				name:'WIDE_TELE',
				type:'String'
			},{
				name:'CREATOR',
				type:'String'
			},{
				name:'CREATE_TIME',
				type:'String'
			}]);
			// Store对象将使用配置 的DataProxy的实现类来加载数据
			var store = new Ext.data.Store({
				proxy : new Ext.data.DWRProxy(keyMgr.findNewTOrder, true),
				reader : new Ext.data.ListRangeReader({
							totalProperty : 'totalSize',
							root : 'data',
							id : 'torder_id'
						}, dataRecords)
				//remoteSort : true
			});
			// 创建grid窗体
			var grid = new Ext.grid.GridPanel({
					store : store,
					loadMask : {
						msg : '数据加载中...'
					},
					sm : sm,
					cm : cm,
					height : 400,
					width : 760,
					frame : true,
					autoExpandMax :true,//自动扩展列宽度width : 800,
					tbar:[					    
						{
							id: 'keyword',
							xtype:'textfield',
							x:0,
							emptyText:'请输入条件后按enter',
							style:'width:120px;'
						}
					],					
					bbar : new Ext.PagingToolbar({
							pageSize : pageSize,
							store : store,
							displayInfo : true,
							emptyMsg :'没有记录',
							displayMsg :'显示{0}-{1}条 共{2}条',
							plugins : new Ext.ux.ProgressBarPager()							
						})
				});
				var keyword="";
				grid.render('com-div');
				store.baseParams.keyword=keyword;
				store.load({
				params : {
					start : 0,
					limit : pageSize,
					keyword:keyword
				}
				});
				var keywordObj=window.document.getElementById('keyword');
				keywordObj.οnkeydοwn=function(){
					if(window.event.keyCode=='13'){		
						   keyword = keywordObj.value;		
						   if(keyword.length < 1){
							   Ext.MessageBox.alert("status","关键字不能为空! ");
							   return;
						   }		 
						   store.baseParams =[{}];
						   store.baseParams.keyword = keyword;
						   store.reload({params:{start:0,limit:pageSize,keyword:keyword}});
					}
				}
	});

 

 

SERVICE实现:

 

public ListRange findNewTOrder(Map<String, String> map) {
		List list=null;
		list=this.keyMgrDao.findNewTOrderDao(map);
		return new ListRange(list.toArray(),this.keyMgrDao.findNewTOrderTotalDao(map));
	}

 

 

DAO实现:

 

public List findNewTOrderDao(Map<String, String> map) {
  Map m=new HashMap();
  Long start=null;
  Long end=null;
  Long limit=null;
  limit=new Long(map.get("limit"));
  start=new Long(map.get("start"));
  end=start+limit;
  System.out.println("limit:"+limit);
  System.out.println("start:"+start);
  m.put("start", start);
  m.put("end", end);
  m.put("keyword", map.get("keyword").toString());
  return this.getSqlMapClientTemplate().queryForList("telecom_order.findNewTOrderSql",m);
 }

 public String findNewTOrderTotalDao(Map<String, String> map) {
  String str="0";
  List list=null;
  list=this.getSqlMapClientTemplate().queryForList("telecom_order.findNewTOrderTotalSql",map);
  if(list!=null&&list.size()>0){
   Map m=new HashMap();
   m=(Map)list.get(0);
   str=m.get("COUNT").toString();
  }
  System.out.println("total:" + str);
  return str;

 }

 

IBATIS SQL:

 

<!--根据条件查找电信新KEY工单 -->
	<select id="findNewTOrderSql" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		<![CDATA[
		select * 
  			from (select row_.*, rownum rownum_ 
	          from (
	          	select t.torder_id,t.TORDER_CODE,t.PACKAGE_TYPE,t.MONEY,t.AREA,t.CUST_NAME,t.USER_FLAG,(case when t.SEX=1 then '男' else '女' end) as SEX,t.TELEPHONE,t.IDCARD,t.ADDRESS,t.WIDE_CODE,t.WIDE_TELE,t.CREATOR,to_char(t.CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') as CREATE_TIME from TELECOM_ORDER t 
          		where t.ORDER_TYPE_ID=1 and t.STATUS=1 
          		and t.TORDER_ID||t.PACKAGE_TYPE||t.TORDER_CODE||t.MONEY||t.AREA||t.CUST_NAME||t.USER_FLAG||t.E_USER_FLAG||t.SEX||t.TELEPHONE||t.IDCARD||t.ADDRESS||t.WIDE_CODE||t.WIDE_TELE||t.CREATOR||t.CREATE_TIME like '%$keyword$%'
	          ) row_ 
         		where rownum <= #end#) 
			where rownum_ > #start# 
		]]>
	</select>
	<!--根据条件查找电信新KEY工单总数 -->
	<select id="findNewTOrderTotalSql" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		select count(1) as count from TELECOM_ORDER t where t.ORDER_TYPE_ID=1 and t.STATUS=1 
		and t.TORDER_ID||t.PACKAGE_TYPE||t.TORDER_CODE||t.MONEY||t.AREA||t.CUST_NAME||t.USER_FLAG||t.E_USER_FLAG||t.SEX||t.TELEPHONE||t.IDCARD||t.ADDRESS||t.WIDE_CODE||t.WIDE_TELE||t.CREATOR||t.CREATE_TIME like '%$keyword$%'
	</select>

 dwr+spring配置简单,就不贴上来了 。

深圳人才网 深圳招聘网 深圳人才招聘网 深圳人才大市场 

企业、个人免费注册,获取想要的 深圳 软件工程师招聘信息 月薪最低3000-8000,更有高端猎头职位! 

www.szrcwz.com                                                                                                                                           

                  Google 提供的广告

posted @ 2010-09-28 13:15  栈长  阅读(119)  评论(0编辑  收藏  举报