日期:2014-05-16 浏览次数:20536 次
1. Ext.data.DWRProxy = function(dwrCall, pagingAndSort) 2. { 3. Ext.data.DWRProxy.superclass.constructor.call(this); 4. this.dwrCall = dwrCall; 5. //this.args = args; 6. this.pagingAndSort = (pagingAndSort!=undefined ? pagingAndSort : true); 7. }; 8. 9. Ext.extend 10. ( 11. Ext.data.DWRProxy, 12. Ext.data.DataProxy, 13. { 14. load : function(params, reader, callback, scope, arg) 15. { 16. if(this.fireEvent("beforeload", this, params) !== false) 17. { 18. var sort; 19. 20. if(params.sort && params.dir) 21. sort = params.sort + ' ' + params.dir; 22. else 23. sort = ''; 24. 25. var delegate = this.loadResponse.createDelegate(this, [reader, callback, scope, arg], 1); 26. var callParams = new Array(); 27. 28. if(arg.arg) 29. { 30. callParams = arg.arg.slice(); 31. } 32. 33. if(this.pagingAndSort) 34. { 35. callParams.push(params.start); 36. callParams.push(params.limit); 37. callParams.push(sort); 38. } 39. 40. callParams.push(delegate); 41. this.dwrCall.apply(this, callParams); 42. } 43. else 44. { 45. callback.call(scope || this, null, arg, false); 46. } 47. }, 48. 49. loadResponse : function(listRange, reader, callback, scope, arg) 50. { 51. var result; 52. try 53. { 54. result = reader.readRecords(listRange.evalJSON()); 55. } 56. catch(e) 57. { 58. this.fireEvent("loadexception", this, null, response, e); 59. callback.call(scope, null, arg, false); 60. return; 61. } 62. callback.call(scope, result, arg, true); 63. }, 64. 65. update : function(dataSet){}, 66. 67. updateResponse : function(dataSet) 68. {} 69. } 70. ); 71. 72. Ext.data.ListRangeReader = function(meta, recordType) 73. { 74. Ext.data.ListRangeReader.superclass.constructor.call(this, meta, recordType); 75. this.recordType = recordType; 76. }; 77. Ext.extend 78. ( 79. Ext.data.ListRangeReader, 80. Ext.data.DataReader, 81. { 82. getJsonAccessor: function() 83. { 84. var re = /[[.]/; 85. return function(expr) 86. { 87. try 88. { 89. return(re.test(expr))? new Function("obj", "return obj." + expr): function(obj){return obj[expr];}; 90. } 91. catch(e) 92. {} 93. return Ext.emptyFn; 94. }; 95. }(), 96. 97. read : function(o) 98. { 99. var recordType = this.recordType, fields = recordType.prototype.fields; 100. //Generate extraction functions for the totalProper