Ext.grid.Panel表格分页存储过程

  /*首先需要引入两个Extjs插件类  Ext.ux.data.PagingMemoryProxy和Ext.ux.ProgressBarPager这两个类*/

 /*下面是控制弹出窗体放大缩小时窗体居中的方法*/ 1 var HotalOrderResizeCenterWindow;
  2 Ext.EventManager.onWindowResize(function() {
  3     if (HotalOrderResizeCenterWindow) {
  4         HotalOrderResizeCenterWindow.setHeight(480);
  5         HotalOrderResizeCenterWindow.setWidth(1225);
  6         HotalOrderResizeCenterWindow.center()
  7     }
  8 });
  9
  /*下面这个方法是根据加载STORE值时,控制某字段样式的*/
 11 function changeIsOrNoReturnRoom(val) {
 12     if (val == ‘未退房‘) {
 13         return ‘<span style="color:black;">‘ + val + ‘</span>‘
 14     } else if (val == "已退房") {
 15         return ‘<span style="color:red;">‘ + val + ‘</span>‘
 16     }
 17     return val
 18 }
 19
 20   /*store的实体类*/
 21 Ext.define(‘RoomOrder‘, {
 22     extend: ‘Ext.data.Model‘,
 23     idProperty: ‘roomorder‘,
 24     fields: [{
 25         name: ‘orderId‘
 26     }, {
 27         name: ‘orderForAdmin‘
 28     }, {
 29         name: ‘orderCustomerName‘
 30     }, {
 31         name: ‘orderCustomerIDcard‘
 32     }, {
 33         name: ‘orderCustomerPhone‘
 34     }, {
 35         name: ‘orderRoomNumber‘
 36     }, {
 37         name: ‘orderRoomPrice‘,
 38         type: ‘float‘
 39     }, {
 40         name: ‘orderCashPledge‘,
 41         type: ‘float‘
 42     }, {
 43         name: ‘orderOpenRoomTime‘
 44     }, {
 45         name: ‘orderRuleReturnRoomTime‘
 46     }, {
 47         name: ‘orderCheckInDayCount‘
 48     }, {
 49         name: ‘orderIsOrNoReturnRoom‘
 50     }, {
 51         name: ‘orderReturnRoomTime‘
 52     }]
 53 });
 54
 55   /*gride的store*/
 56 var store = Ext.create(‘Ext.data.Store‘, {
 57     model: ‘RoomOrder‘,
 58     pageSize: 3,/*这个参数就是每页加载数据的条数,这个参数都会在你POST或GET时,自动加为参数*/
 59     autoLoad: true,
 60     proxy: {
 61         type: ‘ajax‘,
 62         url: ‘shareMediumPage.ashx‘,
 63         reader: {
 64             root: ‘data‘,                       /*totalProperty这个字段很重要是符合查询条件的所有数据的总条数,虽然查询时只需要查询出需要的部分,但是返回的数据中必须加上这个总数量字段,这个字段原本在你数据库的表中肯定是没有,需要你反回数据时自加上,后面数据库部分有说明*/
 65             totalProperty: ‘allCount‘
 66         },
 67         extraParams: {
 68             sign: ‘12‘,
 69             loadSign: ‘0‘
 70         }
 71     },
 72     remoteSort: true,
 73     listeners: {
 74         beforeload: function() {}
 75     }
 76 });   /*gride的tabbar*/
 77 var orderContronllerBar = Ext.create("Ext.Toolbar", {
 78     items: [‘‘, "-",
 79     {
 80         xtype: "splitbutton",
 81         text: ‘未退房‘,
 82         menu: true,
 83         handler: function() {
 84             alert("liaohang")
 85         },
 86     }, ‘‘, "-",
 87     {
 88         xtype: "splitbutton",
 89         text: ‘已退房‘,
 90         handler: function() {
 91             alert("liaohang")
 92         }
 93     }, "关键字:",
 94     {
 95         xtype: ‘textfield‘,
 96         id: ‘searchBar‘
 97     }, {
 98         xtype: ‘button‘,
 99         text: "搜索",
100         handler: function() {
101             alert("al;ksdfjaljdsfljfas") store.load({
102                 params: {
103                     keyword: Ext.getCmp("searchBar").getValue()
104                 }
105             })
106         }
107     }]
108 });
109
110   /*grid类*/
111 Ext.define(‘HotalOrderWindowContentPanelClass‘, {
112     extend: ‘Ext.grid.Panel‘,
113     xtype: ‘OrderPanelXtype‘,
114     id: "orderListGridPanel",
115     title: ‘订单‘,
116     store: store,
117     columns: [new Ext.grid.RowNumberer({
118         text: "序号",
119         width: 40,
120         dataIndex: function(value, metadata, record, rowIndex) {
121             return 1 + rowIndex
122         }
123     }),
124     {
125         id: ‘orderCustomerName‘,
126         text: ‘姓名‘,
127         sortable: true,
128         dataIndex: ‘orderCustomerName‘,
129         width: 75
130     }, {
131         text: ‘身份证号‘,
132         sortable: true,
133         dataIndex: ‘orderCustomerIDcard‘,
134         width: 175
135     }, {
136         text: ‘电话‘,
137         sortable: true,
138         dataIndex: ‘orderCustomerPhone‘,
139         width: 120
140     }, {
141         text: ‘房号‘,
142         sortable: true,
143         dataIndex: ‘orderRoomNumber‘,
144         width: 100
145     }, {
146         text: ‘价格‘,
147         sortable: true,
148         renderer: Ext.util.Format.usMoney,
149         dataIndex: ‘orderRoomPrice‘,
150         width: 100
151     }, {
152         text: ‘押金‘,
153         sortable: true,
154         renderer: Ext.util.Format.usMoney,
155         dataIndex: ‘orderCashPledge‘,
156         width: 100
157     }, {
158         text: ‘入住时间‘,
159         sortable: true,
160         dataIndex: ‘orderOpenRoomTime‘,
161         width: 125
162     }, {
163         text: ‘必须退房时间‘,
164         sortable: true,
165         dataIndex: ‘orderRuleReturnRoomTime‘,
166         width: 125
167     }, {
168         text: ‘入住天数‘,
169         sortable: true,
170         dataIndex: ‘orderCheckInDayCount‘,
171         width: 75
172     }, {
173         text: ‘是否退房‘,
174         sortable: true,
175         renderer: changeIsOrNoReturnRoom,
176         dataIndex: ‘orderIsOrNoReturnRoom‘,
177         width: 75
178     }, {
179         text: ‘退房时间‘,
180         sortable: true,
181         dataIndex: ‘orderReturnRoomTime‘,
182         width: 134
183     }],
184     stripeRows: true,
185     tbar: orderContronllerBar,
186     height: 450,
187     width: 1210,
188     frame: true,
189     bbar: Ext.create(‘Ext.PagingToolbar‘, {
190         store: store,
191         displayInfo: true,
192         plugins: Ext.create(‘Ext.ux.ProgressBarPager‘, {})
193     })
194 })
195
196
197   /*主窗体*/
198  Ext.define("HotalOrderWindowClass", {
199     extend: "Ext.window.Window",
200     requests: [],
201     id: ‘HotalOrderManagerWindow‘,
202     xtype: ‘HotalOrderManagerXtype‘,
203     title: "订单管理",
204     height: 480,
205     width: 1225,
206     autoRender: true,
207     region: ‘center‘,
208     autoScroll: false,
209     closable: true,
210     border: 0,
211     plain: true,
212     layout: ‘border‘,
213     closeAction: ‘hide‘,
214     draggable: true,
215     floating: true,
216     items: [{
217         xtype: ‘OrderPanelXtype‘,
218         title: ‘‘,
219         frame: true,
220     }],
221     listeners: {
222         ‘show‘: function(e) {},
223         ‘beforeshow‘: function(o) {
224             HotalOrderResizeCenterWindow = o
225         },
226         ‘destroy‘: function(o) {
227             HotalOrderResizeCenterWindow = null
228         }
229     }
230 })

/*Post页面代码  shareMediumPage.ashx*/

 1  public void ProcessRequest(HttpContext context)
 2      {
 3          HttpResponse res = context.Response;
 4          shareMediumPage master = new shareMediumPage();
 5          HttpRequest req = context.Request;
 6          JavaScriptSerializer jss = new JavaScriptSerializer();
 7          int sgin =Convert.ToInt32( req["sign"]);
 8          string adminName = "adsfasaf";
 9          int sPage = Convert.ToInt32(req["page"]);//extjs自加的参数
10          int sStart = Convert.ToInt32(req["start"]);//extjs自加的参数
11          int sLimit = Convert.ToInt32(req["limit"]);//extjs自加的参数
12           //由于我们是在存储过程中处理的,所以三个参数中我们只需要两个 sPage, sLimit
13
14          string currentDatetime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
15          currentDatetime = Convert.ToDateTime(currentDatetime).Ticks.ToString();
16          res.Write(OptionLoadOrder(req["loadSign"].ToString(), adminName, currentDatetime, sPage, sLimit));
17          res.ContentType = "text/plain";
18          res.End();
19
20      }
 1  public String OptionLoadOrder(string loadSign, string adminName, string currentDatetime, int pageIndex, int pageSize)
 2       {
 3
 4           shareParameter = new SqlParameter[] { new SqlParameter("@loadSign", loadSign), new SqlParameter("@adminName", adminName), new SqlParameter("@currentDatetime", currentDatetime)
 5             , new SqlParameter("@PageIndex", pageIndex), new SqlParameter("@PageSize", pageSize)};
 6           SqlDataReader reader = SqlHelper.SqlHelper.ExecuteReader(SqlHelper.SqlHelper.connecString, "proc_AccodingPassTypeLoadOrder", shareParameter);
 7
 8           ORDERLIST list = new ORDERLIST();
 9           List<orderClass> data = new List<orderClass>();
10
11           while (reader.Read())
12           {
13               list.allCount=Convert.ToInt32(reader["allCount"]);
14               orderClass order = new orderClass();
15               order.orderId = reader["orderId"].ToString();
16               order.orderForAdmin = reader["orderForAdmin"].ToString();
17
18               order.orderCustomerName = reader["orderCustomerName"].ToString();
19               order.orderCustomerIDcard = reader["orderCustomerIDcard"].ToString();
20               order.orderCustomerPhone = reader["orderCustomerPhone"].ToString();
21               order.orderRoomNumber = reader["orderRoomNumber"].ToString();
22               order.orderRoomPrice = reader["orderRoomPrice"].ToString();
23               order.orderCashPledge = reader["orderCashPledge"].ToString();
24               order.orderOpenRoomTime = reader["orderOpenRoomTime"].ToString();
25               order.orderRuleReturnRoomTime = reader["orderRuleReturnRoomTime"].ToString();
26               order.orderCheckInDayCount = reader["orderCheckInDayCount"].ToString();
27               order.orderIsOrNoReturnRoom = reader["orderIsOrNoReturnRoom"].ToString();
28               order.orderReturnRoomTime = reader["orderReturnRoomTime"].ToString();
29               data.Add(order);
30           }
31
32           list.data = data;
33           return jss.Serialize(list);
34       }

/*数据库存储过程*/

 1 create proc [dbo].[proc_AccodingPassTypeLoadOrder]
 2
 3  @loadSign varchar(50),
 4  @adminName  varchar(50),
 5  @currentDatetime varchar(50),
 6  @PageIndex int, /*第几页*/
 7   @PageSize int  /*每页的行数*/
 8 as
 9 declare @BeginRow int
10 declare @EndRow int
11
12 set @BeginRow=@PageSize*(@PageIndex-1)+1; /*获得分页第一行所在位置*/
13 set @EndRow=@PageSize*@PageIndex;/*获得分页最后一行所在位置*/
14 declare @allCount int/*这个参数就是存放符合条件的所有数据总数量,然后加入返回数据中作为一个字段*/
15 if(@loadSign=0) --加载所有
16 begin
17 select @allCount=COUNT(*) from hotalOrderSheet where orderForAdmin=@adminName
18  select * from (select ROW_NUMBER() over(order by(orderId)) as RowIndex,@allCount as allCount, * from hotalOrderSheet where orderForAdmin=@adminName) as a
19 where RowIndex between @BeginRow and @EndRow
20 --select * from hotalOrderSheet
21
22 end
23 else if(@loadSign=1)--未退房
24 begin
25 select @allCount=COUNT(*) from hotalOrderSheet where orderForAdmin=@adminName and orderIsOrNoReturnRoom is null  and orderReturnRoomTime is null
26 select * from (select ROW_NUMBER() over(order by(orderId)) as RowIndex,@allCount as allCount,* from hotalOrderSheet  where orderForAdmin=@adminName and    orderIsOrNoReturnRoom is null  and orderReturnRoomTime is null) as a
27 where RowIndex between @BeginRow and @EndRow
28
29
30 end
31 else if(@loadSign=2)--已退房
32 begin
33
34 select @allCount=COUNT(*) from hotalOrderSheet where orderForAdmin=@adminName and orderIsOrNoReturnRoom is not null    and orderReturnRoomTime is not null
35 select * from (select ROW_NUMBER() over(order by(orderId)) as RowIndex,@allCount as allCount,* from hotalOrderSheet  where orderForAdmin=@adminName and    orderIsOrNoReturnRoom is not null  and orderReturnRoomTime is not null) as a
36 where RowIndex between @BeginRow and @EndRow
37
38 end
39 else if(@loadSign=3)--超时退房用户
40 begin
41
42
43 select @allCount=COUNT(*) from dbo.getOverTimeReturnCustomerList(@adminName,@currentDatetime)
44 select * from  (select ROW_NUMBER() over(order by(orderId)) as RowIndex, @allCount as allCount, * from  dbo.getOverTimeReturnCustomerList(@adminName,@currentDatetime)) as a
45 where RowIndex between @BeginRow and @EndRow
46 end

下面是效果图

时间: 2024-10-09 06:31:49

Ext.grid.Panel表格分页存储过程的相关文章

Ext.grid.Panel表格特性Feature

Ext.grid.feature.Feature是一类针对Ext.grid.Panel 的特殊插件,提供了可以被扩展的基本模板方法.子类包括: 1.Ext.grid.feature.RowBody 表格行体 行体特性为表格追加了tr标签,跨越了原始表格的所有列,在表格中展示一些描述性的特殊信息时非常有用,行体在默认状态下是隐藏的,如果需要展示行体必须覆盖getAdditionalData方法,代码如下: //Ext.grid.feature.RowBody示例 Ext.onReady(funct

【extjs】 ext5 Ext.grid.Panel 分页,搜索

带有分页,搜索的grid. <%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" pageEncoding="UTF-8" %> <html> <head> <jsp:include page="../common/resource_classic.jsp"

【extjs】 extjs5 Ext.grid.Panel 搜索示例

先看效果图: 页面js: <script type="text/javascript"> /** * 日志类型 store * */ var logTypeStore = Ext.create('Ext.data.Store', { fields: ['type', 'name'], data : [ {"type":"1", "name":"登录日志"}, {"type":

完善ext.grid.panel中的查询功能(紧接上一篇)

今天的代码主要是实现,Ext.grid.panel中的查询,其实我也是一名extjs新手,开始想的实现方式是另外再创建一个新的grid类来存放查询出的数据(就是有几个分类查询就创建几个grid类),这样虽然实现了,但是多写了不少代码,之后网上找到了方法. 代码如下:请结合昨天的代码看,否则你是看不明白的 /*我们操作查询的功能键是放在grid的tabbar中的,下面就是创建的grid的tabbar,其中查询操作就在其中,此代码紧接上一篇文章,这个类上一篇文章中也有,但是没有实现查询功能,红色字体

Ext.grid.plugin.RowExpander的简单用法

有时候,我们在grid里渲染数据时,由于某些字段的内容太长,而grid又不会自动出现滚动条,于是溢出的内容后面就会出现省略号, 导致信息展示不完全.如果,这个信息不太重要,展示不完全也无关紧要.可是,有时候,用户需要查看溢出部分的详细内容时,怎么办呢?比如下图中的grid: 因为信息内容太长,导致“消息内容”展示不全,这时候想要查看详细信息怎么办呢? 最简单的解决方法就是利用 Ext.grid.plugin.RowExpander  我们在grid配置项里面添加一个plugins属性.如下图所示

ExtJS4.2 grid panel双击事件

Ext.create('Ext.grid.Panel', {            store: relationStore,              listeners:{              itemdblclick:function(dataview, record, item, index, e){              }},            columns: [                { text: 'id',  dataIndex: 'id' , flex

ext:grid分页,列宽度自动填满grid宽度

var cm = new Ext.grid.ColumnModel([{      header : '编号',      dataIndex : 'id'     }, {      header : '名称',      dataIndex : 'name'     }, {      header : '描述',      dataIndex : 'descn'     }]);   var store = new Ext.data.Store({      proxy : new Ext

ExtJS4.2学习(六)表格分页与通过后台脚本获得分页数据

鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-11-12/175.html ------------------------------------------------------------------------------------------ 效果图: 这里用servlet技术简单处理下: UserServices.java package cn.com.shuyangyang.servi

Ext.grid.ColumnModel

http://szz0429-126-com.iteye.com/blog/978195 http://www.studyofnet.com/news/136.html (非原创) 2.如何在表格中添加CheckBox呢? var sm = new Ext.grid.CheckboxSelectionModel();var cm = new Ext.grid.ColumnModel([    new Ext.grid.RowNumberer(),//自动行号    sm,//添加的地方    {