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