You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.8 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-data-MemoryProxy-method-constructor'><span id='Ext-data-MemoryProxy'>/**
  19. </span></span> * @class Ext.data.MemoryProxy
  20. * @extends Ext.data.DataProxy
  21. * An implementation of Ext.data.DataProxy that simply passes the data specified in its constructor
  22. * to the Reader when its load method is called.
  23. * @constructor
  24. * @param {Object} data The data object which the Reader uses to construct a block of Ext.data.Records.
  25. */
  26. Ext.data.MemoryProxy = function(data){
  27. // Must define a dummy api with &quot;read&quot; action to satisfy DataProxy#doRequest and Ext.data.Api#prepare *before* calling super
  28. var api = {};
  29. api[Ext.data.Api.actions.read] = true;
  30. Ext.data.MemoryProxy.superclass.constructor.call(this, {
  31. api: api
  32. });
  33. this.data = data;
  34. };
  35. Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
  36. <span id='Ext-data-MemoryProxy-event-loadexception'> /**
  37. </span> * @event loadexception
  38. * Fires if an exception occurs in the Proxy during data loading. Note that this event is also relayed
  39. * through {@link Ext.data.Store}, so you can listen for it directly on any Store instance.
  40. * @param {Object} this
  41. * @param {Object} arg The callback's arg object passed to the {@link #load} function
  42. * @param {Object} null This parameter does not apply and will always be null for MemoryProxy
  43. * @param {Error} e The JavaScript Error object caught if the configured Reader could not read the data
  44. */
  45. <span id='Ext-data-MemoryProxy-method-doRequest'> /**
  46. </span> * MemoryProxy implementation of DataProxy#doRequest
  47. * @param {String} action
  48. * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null
  49. * @param {Object} params An object containing properties which are to be used as HTTP parameters
  50. * for the request to the remote server.
  51. * @param {Ext.data.DataReader} reader The Reader object which converts the data
  52. * object into a block of Ext.data.Records.
  53. * @param {Function} callback The function into which to pass the block of Ext.data.Records.
  54. * The function must be passed &lt;ul&gt;
  55. * &lt;li&gt;The Record block object&lt;/li&gt;
  56. * &lt;li&gt;The &quot;arg&quot; argument from the load function&lt;/li&gt;
  57. * &lt;li&gt;A boolean success indicator&lt;/li&gt;
  58. * &lt;/ul&gt;
  59. * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback function is executed. Defaults to the browser window.
  60. * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
  61. */
  62. doRequest : function(action, rs, params, reader, callback, scope, arg) {
  63. // No implementation for CRUD in MemoryProxy. Assumes all actions are 'load'
  64. params = params || {};
  65. var result;
  66. try {
  67. result = reader.readRecords(this.data);
  68. }catch(e){
  69. // @deprecated loadexception
  70. this.fireEvent(&quot;loadexception&quot;, this, null, arg, e);
  71. this.fireEvent('exception', this, 'response', action, arg, null, e);
  72. callback.call(scope, null, arg, false);
  73. return;
  74. }
  75. callback.call(scope, result, arg, true);
  76. }
  77. });</pre>
  78. </body>
  79. </html>