Ext.data.PageMethodHttpProxy
这个类是自动完成对AspNet [System.Web.Services.WebMethod]方法的调用。该方法适合ie,chrome,firefox
/*Ext.data.PageMethodHttpProxy*/ Ext.data.PageMethodHttpProxy = function(method, params, otherConfig) { var A = { method: 'POST', timeout: EnjoyWork.AjaxCallTimeOut, headers: { 'Content-Type': 'application/json;charset=utf-8' } }; Ext.data.PageMethodHttpProxy.superclass.constructor.call(this, A); this.pageMethod = method; this.pageUrl = location.href.split("?")[0]; this.conn = A; var tempApi = new Object(); if (method != null) { this.conn.url = this.pageUrl + '/' + method; tempApi.read = { url: this.conn.url }; } else { this.conn.url = null; } /*改造传入的API*/ if (otherConfig != null) { for (var item in otherConfig) { var old = eval("otherConfig." + item); old = this.pageUrl + "/" + old; eval("otherConfig." + item + "='" + old + "'"); } //应用tempApi没有设置的 Ext.applyIf(tempApi, otherConfig); } this.setApi(tempApi); this.useAjax = !this.conn || !this.conn.events; this.on("beforeload", function(o, p) { Ext.applyIf(p, params); //以下是对传入的参数进行改造 var newObject = new Object(); Ext.apply(newObject, p); for (var i in p) { eval("delete p." + i); } p["isJson"] = true; p["jsonData"] = newObject; }, this); }; Ext.extend(Ext.data.PageMethodHttpProxy,Ext.data.HttpProxy);
同时需要修改Ext-all.js 查找typeof (params[reader.meta.root]
修改判断条件为
if (typeof (params[reader.meta.root]) === 'object' ||
(params["isJson"] == true && params["jsonData"] != null)) {
o.jsonData = params["jsonData"];
} else {
o.params = params || {};
}
posted on 2009-10-04 01:13 fredli2005 阅读(269) 评论(0) 编辑 收藏 举报