1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @class Ext.data.MemoryProxy |
---|
11 | * @extends Ext.data.DataProxy |
---|
12 | * An implementation of Ext.data.DataProxy that simply passes the data specified in its constructor |
---|
13 | * to the Reader when its load method is called. |
---|
14 | * @constructor |
---|
15 | * @param {Object} data The data object which the Reader uses to construct a block of Ext.data.Records. |
---|
16 | */ |
---|
17 | Ext.data.MemoryProxy = function(data){ |
---|
18 | Ext.data.MemoryProxy.superclass.constructor.call(this); |
---|
19 | this.data = data; |
---|
20 | }; |
---|
21 | |
---|
22 | Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, { |
---|
23 | /** |
---|
24 | * @event loadexception |
---|
25 | * Fires if an exception occurs in the Proxy during data loading. Note that this event is also relayed |
---|
26 | * through {@link Ext.data.Store}, so you can listen for it directly on any Store instance. |
---|
27 | * @param {Object} this |
---|
28 | * @param {Object} arg The callback's arg object passed to the {@link #load} function |
---|
29 | * @param {Object} null This parameter does not apply and will always be null for MemoryProxy |
---|
30 | * @param {Error} e The JavaScript Error object caught if the configured Reader could not read the data |
---|
31 | */ |
---|
32 | |
---|
33 | /** |
---|
34 | * Load data from the requested source (in this case an in-memory |
---|
35 | * data object passed to the constructor), read the data object into |
---|
36 | * a block of Ext.data.Records using the passed Ext.data.DataReader implementation, and |
---|
37 | * process that block using the passed callback. |
---|
38 | * @param {Object} params This parameter is not used by the MemoryProxy class. |
---|
39 | * @param {Ext.data.DataReader} reader The Reader object which converts the data |
---|
40 | * object into a block of Ext.data.Records. |
---|
41 | * @param {Function} callback The function into which to pass the block of Ext.data.records. |
---|
42 | * The function must be passed <ul> |
---|
43 | * <li>The Record block object</li> |
---|
44 | * <li>The "arg" argument from the load function</li> |
---|
45 | * <li>A boolean success indicator</li> |
---|
46 | * </ul> |
---|
47 | * @param {Object} scope The scope in which to call the callback |
---|
48 | * @param {Object} arg An optional argument which is passed to the callback as its second parameter. |
---|
49 | */ |
---|
50 | load : function(params, reader, callback, scope, arg){ |
---|
51 | params = params || {}; |
---|
52 | var result; |
---|
53 | try { |
---|
54 | result = reader.readRecords(this.data); |
---|
55 | }catch(e){ |
---|
56 | this.fireEvent("loadexception", this, arg, null, e); |
---|
57 | callback.call(scope, null, arg, false); |
---|
58 | return; |
---|
59 | } |
---|
60 | callback.call(scope, result, arg, true); |
---|
61 | }, |
---|
62 | |
---|
63 | // private |
---|
64 | update : function(params, records){ |
---|
65 | |
---|
66 | } |
---|
67 | }); |
---|