第二节:ExtJS调用WCF系列-----分页排序列表实现

打开第一节中的那个项目,新建一个Paging.aspx的页面来实现分页列表。
这次我们使用一个测试的数据库CompanyInfoDB,里面有两张表,部门和员工,并外键关联,数据库调用采用Linq的Sqlmetal 命令方式,在Visual Studio 2008的命令提示符中输入以下命令:D:\Program Files\Microsoft Visual Studio 9.0\VC>sqlmetal /conn:server=172.16.1.52;database=CompanyInfoDB;uid=sa;pwd=sa123456 /map:c:\LinqTemp\CompanyInfoDB.map
/code:c:\LinqTemp\CompanyInfoDB.cs /serialization:Unidirectional
然后把生成的CompayInfo.map 文件和CompanyInfo.cs文件加入到项目中,并添加System.Data.Linq的引用,还要修改一下Web.Config 加入数据库链接字符串和XmlMappingSource文件的位置。
<connectionStrings>
  <add name="CompanyInfoDBConnectionString" connectionString="Data Source=172.16.1.52;Initial Catalog=CompanyInfoDB;Persist Security Info=True;User ID=sa;Password=sa123456" providerName="System.Data.SqlClient"/>
 </connectionStrings>
<appSettings>
    <add key="CompanyInfoDBXmlMappingSource" value="E:\ExtJS\ExtJS调用WCF系列博客源文件\ExtJSAndWCFChapter1\ExtJSAndWCFChapter1\DataBase\CompanyInfoDB.map"/>
  </appSettings>

  如图:第二节:ExtJS调用WCF系列-----分页排序列表实现
为了层次更清晰一点,我们新建一个EmployeeBL.cs的类文件来处理Employee的业务逻辑,EmpployeeBL.cs的文件代码如下:

第二节:ExtJS调用WCF系列-----分页排序列表实现using System;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Data;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Configuration;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Linq;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web.Security;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web.UI;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web.UI.HtmlControls;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web.UI.WebControls;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Web.UI.WebControls.WebParts;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Xml.Linq;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Data.Linq.Mapping;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.IO;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Linq.Dynamic;
第二节:ExtJS调用WCF系列-----分页排序列表实现
using System.Runtime.Serialization;
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现
namespace ExtJSAndWCFChapter1
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现    
public class EmployeeBL
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现        CompanyInfoDB ctx;
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现        
//构造函数
第二节:ExtJS调用WCF系列-----分页排序列表实现
        public EmployeeBL()
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            XmlMappingSource xms 
= XmlMappingSource.FromXml(File.ReadAllText(ConfigurationManager.AppSettings["CompanyInfoDBXmlMappingSource"]));
第二节:ExtJS调用WCF系列-----分页排序列表实现            ctx 
= new CompanyInfoDB(ConfigurationManager.ConnectionStrings["CompanyInfoDBConnectionString"].ConnectionString, xms);
第二节:ExtJS调用WCF系列-----分页排序列表实现            
//ctx.Log = Console.Out;
第二节:ExtJS调用WCF系列-----分页排序列表实现
        }

第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现        
public string GetEmployeePaging(int start, int limit, string sort, string dir)
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            
string strJsonSource = "";
第二节:ExtJS调用WCF系列-----分页排序列表实现            var query 
= from emp in ctx.Employee
第二节:ExtJS调用WCF系列-----分页排序列表实现                        select 
new
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                        
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                            EmployeeID 
= emp.EmployeeID,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            CnName 
= emp.CnName,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            Sex 
= emp.Sex,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            Age 
= emp.Age,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            Email 
= emp.Email,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            OnWorkDate 
= emp.OnWorkDate,
第二节:ExtJS调用WCF系列-----分页排序列表实现                            DeptName 
= emp.Department.CnName
第二节:ExtJS调用WCF系列-----分页排序列表实现                        }
;
第二节:ExtJS调用WCF系列-----分页排序列表实现            query 
= query.OrderBy(sort + " " + dir);
第二节:ExtJS调用WCF系列-----分页排序列表实现            
int TotalCount = query.Count(); //共有记录数
第二节:ExtJS调用WCF系列-----分页排序列表实现
            int PageNum = start / limit;  //共有页数 
第二节:ExtJS调用WCF系列-----分页排序列表实现
            int PageSize = limit;         //每页记录数
第二节:ExtJS调用WCF系列-----分页排序列表实现
            query = query.Skip(PageSize * PageNum).Take(PageSize);
第二节:ExtJS调用WCF系列-----分页排序列表实现           
第二节:ExtJS调用WCF系列-----分页排序列表实现            
string JsonSource = query.ToJSON();                      //当前页记录转成JSON格式
第二节:ExtJS调用WCF系列-----分页排序列表实现
            strJsonSource = @"{""TotalCount"":""" + TotalCount + "";
第二节:ExtJS调用WCF系列-----分页排序列表实现            strJsonSource 
= strJsonSource + @""",""EmployeeList"":" + JsonSource + "}";
第二节:ExtJS调用WCF系列-----分页排序列表实现            
return strJsonSource;
第二节:ExtJS调用WCF系列-----分页排序列表实现        }

第二节:ExtJS调用WCF系列-----分页排序列表实现    }

第二节:ExtJS调用WCF系列-----分页排序列表实现}

第二节:ExtJS调用WCF系列-----分页排序列表实现

这里需要两个类文件:Dynamic.cs 和 JSONHelper.cs  前者是微软提供的Linq动态查询文件,后者是scottgu的JSON序列化文件。
并在EmployeeService.svc.cs 文件中加入获取员工的分页排序方法,代码如下

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现 /**//// <summary>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// Employee分页排序
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// </summary>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// <param name="start"></param>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// <param name="limit"></param>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// <param name="sort"></param>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// <param name="dir"></param>
第二节:ExtJS调用WCF系列-----分页排序列表实现        
/// <returns></returns>

第二节:ExtJS调用WCF系列-----分页排序列表实现        [OperationContract]
第二节:ExtJS调用WCF系列-----分页排序列表实现        [WebInvoke(BodyStyle 
= WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetEmployeePaging")]
第二节:ExtJS调用WCF系列-----分页排序列表实现        
public string GetEmployeePaging(int start, int limit, string sort, string dir)
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            
if (start < 0 || sort == ""throw new ArgumentException("参数错误!");
第二节:ExtJS调用WCF系列-----分页排序列表实现            EmployeeBL bl 
= new EmployeeBL();
第二节:ExtJS调用WCF系列-----分页排序列表实现            
return bl.GetEmployeePaging(start, limit, sort, dir);
第二节:ExtJS调用WCF系列-----分页排序列表实现        }

接下来我们编写客户端代码,这次我们新建一个paging.js的文件来存放Paging.Aspx的脚本文件,ExtJS调用WCF的时候有两点须注意:
第一点:关于前一节中
        [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/Get")]中的BodyStyle = WebMessageBodyStyle.Bare  和
        [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetAll")]中的BodyStyle = WebMessageBodyStyle.Wrapped的区别,看前一节的两个例子,我们不难发现两个返回值的不同之处:
Get:
{"Age":28,"Birthday":"\/Date(286732800000+0800)\/","CnName":"Xiaozhuang","Email":"[email protected]","EmployeeID":"b34f963e-8520-44da-be00-bd0a1aeadc78","Sex":true}
GetAll:
{"GetAllResult":[{"Age":28,"Birthday":"\/Date(286732800000+0800)\/","CnName":"CnName","Email":"[email protected]","EmployeeID":"2835ba7e-5f0c-41ff-8746-d6e959800850","Sex":true},{"Age":28,"Birthday":"\/Date(286732800000+0800)\/","CnName":"CnName1","Email":"[email protected]","EmployeeID":"d5b7a088-13a8-4195-8ce9-e0836cd33de4","Sex":false}]}
可以看到GetAll 的返回值给加了一个GetAllResult的根对象,但是这个根对象在ExtJS调用的时候是不需要的,必须去掉这个根对象才行,那么我们为什么不用WebMessageBodyStyle.Bare非要用BodyStyle = WebMessageBodyStyle.Wrapped?那是因为前者只有在WCF方法只有一个输入参数,而且不需要对其进行序列化的时候才可以使用,但是很多方法要求都不止一个参数,所以必须用后者。那我们怎样才能去掉这个根对象呢?在http://erichauser.net/?p=35有个去掉这个根对象的方法,不过他提供的那个文件有问题,不能达到预期的效果,经过调试,我把文件WCFJsonReader.js进行了改进,代码如下:

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现/**//**   
第二节:ExtJS调用WCF系列-----分页排序列表实现 * @class Ext.data.WCFJsonReader  
第二节:ExtJS调用WCF系列-----分页排序列表实现 * @extends Ext.data.JsonReader 
第二节:ExtJS调用WCF系列-----分页排序列表实现 * 
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Custom reader for reading data from WCF.  If you are using WebMessageBodyStyle.Wrapped, then WCF adds a root object to your   
第二节:ExtJS调用WCF系列-----分页排序列表实现 * JSON result: 
第二节:ExtJS调用WCF系列-----分页排序列表实现 *    
第二节:ExtJS调用WCF系列-----分页排序列表实现 * { "MethodResult": { "Count" : 0, "Objects": [ … ] } }   
第二节:ExtJS调用WCF系列-----分页排序列表实现 *  
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Ext does not expect the result to have a root object before parsing, so this class will remove it.    
第二节:ExtJS调用WCF系列-----分页排序列表实现 
*/
  
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现  Ext.data.WCFJsonReader 
= Ext.extend(Ext.data.JsonReader, 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
/**//* @cfg {Boolean} Sets whether or not the OperationContract has the is using WebMessageBodyStyle.Wrapped */  
第二节:ExtJS调用WCF系列-----分页排序列表实现      wrapped: 
true,   
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
/**//**  
第二节:ExtJS调用WCF系列-----分页排序列表实现     * If wrapped is set to true, we will strip WCF’s wrap object    
第二节:ExtJS调用WCF系列-----分页排序列表实现     
*/
  
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现       read : function(response)
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现        var json 
= response.responseText;
第二节:ExtJS调用WCF系列-----分页排序列表实现        var o 
= eval("("+json+")");
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        
if(!o) 第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            
throw 第二节:ExtJS调用WCF系列-----分页排序列表实现{message: "JsonReader.read: Json object not found"};
第二节:ExtJS调用WCF系列-----分页排序列表实现        }

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现      
if (this.wrapped) 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现          
for (var prop in o) 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现              
if (typeof(prop) == 'string' && prop.substr(prop.length-6,prop.length) == 'Result'第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现                  o 
= this.convert(o[prop]); 
第二节:ExtJS调用WCF系列-----分页排序列表实现                  
//o = o[prop]; 
第二节:ExtJS调用WCF系列-----分页排序列表实现
                  break
第二节:ExtJS调用WCF系列-----分页排序列表实现              }
 
第二节:ExtJS调用WCF系列-----分页排序列表实现          }
 
第二节:ExtJS调用WCF系列-----分页排序列表实现     }
 
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现     
if(o.metaData)第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现         delete 
this.ef; 
第二节:ExtJS调用WCF系列-----分页排序列表实现         
this.meta = o.metaData;  
第二节:ExtJS调用WCF系列-----分页排序列表实现         
this.recordType = Ext.data.Record.create(o.metaData.fields);  
第二节:ExtJS调用WCF系列-----分页排序列表实现         
this.onMetaChange(this.meta, this.recordType, o); 
第二节:ExtJS调用WCF系列-----分页排序列表实现     }
  
第二节:ExtJS调用WCF系列-----分页排序列表实现     
return Ext.data.WCFJsonReader.superclass.readRecords.call(this, o); 
第二节:ExtJS调用WCF系列-----分页排序列表实现     }

第二节:ExtJS调用WCF系列-----分页排序列表实现     
//private   
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
     convert : function(o) 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现         o 
= eval("("+o+")");
第二节:ExtJS调用WCF系列-----分页排序列表实现         var newResult 
= new Object(); 
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现         
for (var rootProp in o) 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现             newResult[rootProp] 
= o[rootProp];  
第二节:ExtJS调用WCF系列-----分页排序列表实现         }
  
第二节:ExtJS调用WCF系列-----分页排序列表实现         
return newResult;  
第二节:ExtJS调用WCF系列-----分页排序列表实现      }
  
第二节:ExtJS调用WCF系列-----分页排序列表实现  }
);

在调用WCF的时候,用这个WCFJsonReader.js代替原始的JsonReader就可以了。
第二点:我们在调用WCF的时候要指明Content-type是application/json,而且参数必须要进行JSON序列化才可以,但是在ExtJS提供的分页排序例子中输入参数是直接由GridPanel提供的,所以我们必须截获这些参数,并对它进行JSON序列化,由此我建立了一个WCFHttpProxy.js的文件,这个文件继承自Ext.data.HttpProxy并重载了它的load方法,在这个方法里截获输入参数,并对它们进行JSON序列化。代码如下:

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现/**//*
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Ext JS Library 2.0 RC 1
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Copyright(c) 2006-2007, Ext JS, LLC.
第二节:ExtJS调用WCF系列-----分页排序列表实现 * [email protected]
第二节:ExtJS调用WCF系列-----分页排序列表实现 * 
第二节:ExtJS调用WCF系列-----分页排序列表实现 * http://extjs.com/license
第二节:ExtJS调用WCF系列-----分页排序列表实现 
*/

第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
/**//**
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Author by xiaozhuang
第二节:ExtJS调用WCF系列-----分页排序列表实现 
*/

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现Ext.data.WCFHttpProxy 
= Ext.extend(Ext.data.HttpProxy, 第二节:ExtJS调用WCF系列-----分页排序列表实现{  
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    load : 
function(params, reader, callback, scope, arg)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        
if(this.fireEvent("beforeload"this, params) !== false)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现            Ext.lib.Ajax.defaultPostHeader 
= 'application/json';
第二节:ExtJS调用WCF系列-----分页排序列表实现            params 
= Ext.util.JSON.encode(params);
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            
var  o = 第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                params : params 
|| 第二节:ExtJS调用WCF系列-----分页排序列表实现{},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                request: 
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                    callback : callback,
第二节:ExtJS调用WCF系列-----分页排序列表实现                    scope : scope,
第二节:ExtJS调用WCF系列-----分页排序列表实现                    arg : arg
第二节:ExtJS调用WCF系列-----分页排序列表实现                }
,
第二节:ExtJS调用WCF系列-----分页排序列表实现                reader: reader,
第二节:ExtJS调用WCF系列-----分页排序列表实现                callback : 
this.loadResponse,
第二节:ExtJS调用WCF系列-----分页排序列表实现                scope: 
this
第二节:ExtJS调用WCF系列-----分页排序列表实现            }
;
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            
if(this.useAjax)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                Ext.applyIf(o, 
this.conn);
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
if(this.activeRequest)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                    Ext.Ajax.abort(
this.activeRequest);
第二节:ExtJS调用WCF系列-----分页排序列表实现                }

第二节:ExtJS调用WCF系列-----分页排序列表实现                
this.activeRequest = Ext.Ajax.request(o);
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            }
else第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                
this.conn.request(o);
第二节:ExtJS调用WCF系列-----分页排序列表实现            }

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
else第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            callback.call(scope
||thisnull, arg, false);
第二节:ExtJS调用WCF系列-----分页排序列表实现        }

第二节:ExtJS调用WCF系列-----分页排序列表实现    }

第二节:ExtJS调用WCF系列-----分页排序列表实现}
);

 

其实就是增加了Ext.lib.Ajax.defaultPostHeader = 'application/json';params = Ext.util.JSON.encode(params);两行。

有了这两个文件,我们要改进一下我们的EXTJS,在它的目录下建立WCF的文件夹,并把这两个文件拷贝进去。
现在我们可以编写客户端代码了,Paging.aspx的代码如下:

 

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现<%第二节:ExtJS调用WCF系列-----分页排序列表实现@ Page Language="C#" AutoEventWireup="true" CodeBehind="Paging.aspx.cs" Inherits="ExtJSAndWCFChapter1.Paging" %>
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现
<html xmlns="http://www.w3.org/1999/xhtml" >
第二节:ExtJS调用WCF系列-----分页排序列表实现
<head runat="server">
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<title>Untitled Page</title>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<link rel="stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css" />
第二节:ExtJS调用WCF系列-----分页排序列表实现     
<script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<script type="text/javascript" src="ExtJS/ext-all.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现      
<!-- ExtJS调用WCF的专用文件 -->
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<script type="text/javascript" src="ExtJS/WCF/WCFHttpProxy.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<script type="text/javascript" src="ExtJS/WCF/WCFJsonReader.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现      
<!-- 简体中文语言包 -->
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<script type="text/javascript" src="ExtJS/source/locale/ext-lang-zh_CN.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现     
<!-- 分页排序ExtJS代码 -->
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<script type="text/javascript" src="paging.js"></script>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<!-- Common Styles for the examples -->
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现 
<style type="text/css">第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        body .x-panel 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            margin-bottom
:20px;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        .icon-grid 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            background-image
:url(ExtJS/icons/fam/grid.png) !important;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        #button-grid .x-panel-body 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            border
:1px solid #99bbe8;
第二节:ExtJS调用WCF系列-----分页排序列表实现            border-top
:0 none;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        .add 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            background-image
:url(ExtJS/icons/fam/add.gif) !important;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        .option 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            background-image
:url(ExtJS/icons/fam/plugin.gif) !important;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        .remove 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            background-image
:url(ExtJS/icons/fam/delete.gif) !important;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        .save 
{第二节:ExtJS调用WCF系列-----分页排序列表实现}{
第二节:ExtJS调用WCF系列-----分页排序列表实现            background-image
:url(ExtJS/icons/save.gif) !important;
第二节:ExtJS调用WCF系列-----分页排序列表实现        
}

第二节:ExtJS调用WCF系列-----分页排序列表实现    
</style>
第二节:ExtJS调用WCF系列-----分页排序列表实现
</head>
第二节:ExtJS调用WCF系列-----分页排序列表实现
<body>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
<form id="form1" runat="server">
第二节:ExtJS调用WCF系列-----分页排序列表实现   
<h1>Paging Grid Example</h1><br /><br />
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现
<div id="topic-grid"></div>
第二节:ExtJS调用WCF系列-----分页排序列表实现    
</form>
第二节:ExtJS调用WCF系列-----分页排序列表实现
</body>
第二节:ExtJS调用WCF系列-----分页排序列表实现
</html>
第二节:ExtJS调用WCF系列-----分页排序列表实现

  Paging.js的代码如下:

 

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现/**//*
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现 * Author by Xiaozhuang
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现 * 
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现 * 
第二节:ExtJS调用WCF系列-----分页排序列表实现 
*/

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现Ext.onReady(
function()第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现   
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// create the Data Store
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
    var store = new Ext.data.Store(第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现        
// load using script tags for cross domain, if the data in on the same domain as
第二节:ExtJS调用WCF系列-----分页排序列表实现
        // this page, an HttpProxy would be better
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
        proxy: new Ext.data.WCFHttpProxy(第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            url: '
/EmployeeService.svc/GetEmployeePaging'
第二节:ExtJS调用WCF系列-----分页排序列表实现        }
),
第二节:ExtJS调用WCF系列-----分页排序列表实现     
第二节:ExtJS调用WCF系列-----分页排序列表实现        
// create reader that reads the Topic records
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
        reader: new Ext.data.WCFJsonReader(第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            root: 'EmployeeList',
第二节:ExtJS调用WCF系列-----分页排序列表实现            totalProperty: 'TotalCount',
第二节:ExtJS调用WCF系列-----分页排序列表实现            id: 'EmployeeID',
第二节:ExtJS调用WCF系列-----分页排序列表实现            fields: [
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'EmployeeID', type: 'int'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'CnName', type: 'string'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'Sex', type: 'string'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'Age', type: 'int'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'Email', type: 'string'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'OnWorkDate',type:'string'},
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现                
第二节:ExtJS调用WCF系列-----分页排序列表实现{name: 'DeptName', type: 'string'}
第二节:ExtJS调用WCF系列-----分页排序列表实现            ]
第二节:ExtJS调用WCF系列-----分页排序列表实现        }
),
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现        
// turn on remote sorting
第二节:ExtJS调用WCF系列-----分页排序列表实现
        remoteSort: true
第二节:ExtJS调用WCF系列-----分页排序列表实现    }
);
第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现    store.setDefaultSort('EmployeeID', 'ASC');
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// 把true和false转化为男或者女,这个其实可以在服务器端进行转化,写在这里只是为了测试
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
    function renderSex(value, p, record)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现    
return record.data.Sex=="true"?"":"";
第二节:ExtJS调用WCF系列-----分页排序列表实现    }

第二节:ExtJS调用WCF系列-----分页排序列表实现    
//这个函数演示了怎样把服务器端的DateTime类型转为Javascript的日期
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
    function renderOnWorkDate(value, p, record)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现        
var jsondate = record.data.OnWorkDate;
第二节:ExtJS调用WCF系列-----分页排序列表实现       
return eval("new " + jsondate.substr(1,jsondate.length-2)).toLocaleDateString();
第二节:ExtJS调用WCF系列-----分页排序列表实现    }

第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// the column model has information about grid columns
第二节:ExtJS调用WCF系列-----分页排序列表实现
    // dataIndex maps the column to the specific data field in
第二节:ExtJS调用WCF系列-----分页排序列表实现
    // the data store
第二节:ExtJS调用WCF系列-----分页排序列表实现
    var nm = new Ext.grid.RowNumberer();
第二节:ExtJS调用WCF系列-----分页排序列表实现    
var sm = new Ext.grid.CheckboxSelectionModel();  // add checkbox column
第二节:ExtJS调用WCF系列-----分页排序列表实现

第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
var cm = new Ext.grid.ColumnModel([nm,sm,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"员工ID",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'EmployeeID',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
100
第二节:ExtJS调用WCF系列-----分页排序列表实现
//           renderer: renderTopic
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
       }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"姓名",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'CnName',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
200
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"性别",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'Sex',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
70,
第二节:ExtJS调用WCF系列-----分页排序列表实现           renderer: renderSex
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"年龄",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'Age',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
70
第二节:ExtJS调用WCF系列-----分页排序列表实现           
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现         header: 
"Email",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'Email',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
150
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"入职时间",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'OnWorkDate',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
150,
第二节:ExtJS调用WCF系列-----分页排序列表实现           renderer: renderOnWorkDate
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现           header: 
"部门",
第二节:ExtJS调用WCF系列-----分页排序列表实现           dataIndex: 'DeptName',
第二节:ExtJS调用WCF系列-----分页排序列表实现           width: 
200
第二节:ExtJS调用WCF系列-----分页排序列表实现          
第二节:ExtJS调用WCF系列-----分页排序列表实现        }
]);
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// by default columns are sortable
第二节:ExtJS调用WCF系列-----分页排序列表实现
    cm.defaultSortable = true;
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
var grid = new Ext.grid.GridPanel(第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现        
//el:'topic-grid',
第二节:ExtJS调用WCF系列-----分页排序列表实现
        renderTo: document.body,
第二节:ExtJS调用WCF系列-----分页排序列表实现        width:
800,
第二节:ExtJS调用WCF系列-----分页排序列表实现        height:
500,
第二节:ExtJS调用WCF系列-----分页排序列表实现        title:'分页和排序列表',
第二节:ExtJS调用WCF系列-----分页排序列表实现        store: store,
第二节:ExtJS调用WCF系列-----分页排序列表实现        cm: cm,
第二节:ExtJS调用WCF系列-----分页排序列表实现        trackMouseOver:
false,
第二节:ExtJS调用WCF系列-----分页排序列表实现        sm: sm,
第二节:ExtJS调用WCF系列-----分页排序列表实现        loadMask: 
true,
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        viewConfig: 
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            forceFit:
true,
第二节:ExtJS调用WCF系列-----分页排序列表实现            enableRowBody:
true,
第二节:ExtJS调用WCF系列-----分页排序列表实现            showPreview:
true,
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            getRowClass : 
function(record, rowIndex, p, store)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现               
第二节:ExtJS调用WCF系列-----分页排序列表实现                
return 'x-grid3-row-collapsed';
第二节:ExtJS调用WCF系列-----分页排序列表实现            }

第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,
第二节:ExtJS调用WCF系列-----分页排序列表实现         
// inline toolbars
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
        tbar:[第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            text:'添加',
第二节:ExtJS调用WCF系列-----分页排序列表实现            tooltip:'添加一条记录',
第二节:ExtJS调用WCF系列-----分页排序列表实现            iconCls:'add'
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
, '-', 第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            text:'修改',
第二节:ExtJS调用WCF系列-----分页排序列表实现            tooltip:'修改',
第二节:ExtJS调用WCF系列-----分页排序列表实现            iconCls:'option'
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        }
,'-',第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            text:'删除',
第二节:ExtJS调用WCF系列-----分页排序列表实现            tooltip:'删除记录',
第二节:ExtJS调用WCF系列-----分页排序列表实现            iconCls:'remove',
第二节:ExtJS调用WCF系列-----分页排序列表实现            handler:handleDelete
第二节:ExtJS调用WCF系列-----分页排序列表实现        }
],
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现        bbar: 
new Ext.PagingToolbar(第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现            pageSize: 
25,
第二节:ExtJS调用WCF系列-----分页排序列表实现            store: store,
第二节:ExtJS调用WCF系列-----分页排序列表实现            displayInfo: 
true
第二节:ExtJS调用WCF系列-----分页排序列表实现        }
)
第二节:ExtJS调用WCF系列-----分页排序列表实现    }
);
第二节:ExtJS调用WCF系列-----分页排序列表实现  
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// render it
第二节:ExtJS调用WCF系列-----分页排序列表实现
    grid.render();
第二节:ExtJS调用WCF系列-----分页排序列表实现   
第二节:ExtJS调用WCF系列-----分页排序列表实现
第二节:ExtJS调用WCF系列-----分页排序列表实现    
// trigger the data store load
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现
    var request=第二节:ExtJS调用WCF系列-----分页排序列表实现{start:0,limit:25};
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    store.load(
第二节:ExtJS调用WCF系列-----分页排序列表实现{params:request});
第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现    
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
function handleDelete()第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现      
var selectedKeys = grid.selModel.selections.keys; //returns array of selected rows ids only
第二节:ExtJS调用WCF系列-----分页排序列表实现
            if(selectedKeys.length > 0)
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                Ext.MessageBox.confirm('提示','您确实要删除选定的记录吗?', deleteRecord);
第二节:ExtJS调用WCF系列-----分页排序列表实现            }

第二节:ExtJS调用WCF系列-----分页排序列表实现            
else
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现            
第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现                Ext.MessageBox.alert('提示','请至少选择一条记录!');
第二节:ExtJS调用WCF系列-----分页排序列表实现            }
//end
第二节:ExtJS调用WCF系列-----分页排序列表实现
    }
  
第二节:ExtJS调用WCF系列-----分页排序列表实现   
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现    
function deleteRecord(btn)第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现第二节:ExtJS调用WCF系列-----分页排序列表实现         
if(btn=='yes')第二节:ExtJS调用WCF系列-----分页排序列表实现{
第二节:ExtJS调用WCF系列-----分页排序列表实现               store.reload();
第二节:ExtJS调用WCF系列-----分页排序列表实现            }
//end if click 'yes' on button
第二节:ExtJS调用WCF系列-----分页排序列表实现
        }
 // end deleteRecord
第二节:ExtJS调用WCF系列-----分页排序列表实现

第二节:ExtJS调用WCF系列-----分页排序列表实现        
第二节:ExtJS调用WCF系列-----分页排序列表实现   
第二节:ExtJS调用WCF系列-----分页排序列表实现}
);
第二节:ExtJS调用WCF系列-----分页排序列表实现

运行结果:
第二节:ExtJS调用WCF系列-----分页排序列表实现
源代码下载在这里

转载于:https://www.cnblogs.com/xiaozhuang/archive/2007/12/11/990329.html