3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.data.MemoryProxy"></div>/**
\r
15 * @class Ext.data.MemoryProxy
\r
16 * @extends Ext.data.DataProxy
\r
17 * An implementation of Ext.data.DataProxy that simply passes the data specified in its constructor
\r
18 * to the Reader when its load method is called.
\r
20 * @param {Object} data The data object which the Reader uses to construct a block of Ext.data.Records.
\r
22 Ext.data.MemoryProxy = function(data){
\r
23 // Must define a dummy api with "read" action to satisfy DataProxy#doRequest and Ext.data.Api#prepare *before* calling super
\r
25 api[Ext.data.Api.actions.read] = true;
\r
26 Ext.data.MemoryProxy.superclass.constructor.call(this, {
\r
32 Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
\r
33 <div id="event-Ext.data.MemoryProxy-loadexception"></div>/**
\r
34 * @event loadexception
\r
35 * Fires if an exception occurs in the Proxy during data loading. Note that this event is also relayed
\r
36 * through {@link Ext.data.Store}, so you can listen for it directly on any Store instance.
\r
37 * @param {Object} this
\r
38 * @param {Object} arg The callback's arg object passed to the {@link #load} function
\r
39 * @param {Object} null This parameter does not apply and will always be null for MemoryProxy
\r
40 * @param {Error} e The JavaScript Error object caught if the configured Reader could not read the data
\r
43 <div id="method-Ext.data.MemoryProxy-doRequest"></div>/**
\r
44 * MemoryProxy implementation of DataProxy#doRequest
\r
45 * @param {String} action
\r
46 * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null
\r
47 * @param {Object} params An object containing properties which are to be used as HTTP parameters
\r
48 * for the request to the remote server.
\r
49 * @param {Ext.data.DataReader} reader The Reader object which converts the data
\r
50 * object into a block of Ext.data.Records.
\r
51 * @param {Function} callback The function into which to pass the block of Ext.data.Records.
\r
52 * The function must be passed <ul>
\r
53 * <li>The Record block object</li>
\r
54 * <li>The "arg" argument from the load function</li>
\r
55 * <li>A boolean success indicator</li>
\r
57 * @param {Object} scope The scope in which to call the callback
\r
58 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
\r
60 doRequest : function(action, rs, params, reader, callback, scope, arg) {
\r
61 // No implementation for CRUD in MemoryProxy. Assumes all actions are 'load'
\r
62 params = params || {};
\r
65 result = reader.readRecords(this.data);
\r
67 // @deprecated loadexception
\r
68 this.fireEvent("loadexception", this, null, arg, e);
\r
70 this.fireEvent('exception', this, 'response', action, arg, null, e);
\r
71 callback.call(scope, null, arg, false);
\r
74 callback.call(scope, result, arg, true);
\r