initial import
[roojs1] / Roo / data / MemoryProxy.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11 /**
12  * @class Roo.data.MemoryProxy
13  * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
14  * to the Reader when its load method is called.
15  * @constructor
16  * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
17  */
18 Roo.data.MemoryProxy = function(data){
19     if (data.data) {
20         data = data.data;
21     }
22     Roo.data.MemoryProxy.superclass.constructor.call(this);
23     this.data = data;
24 };
25
26 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
27     /**
28      * Load data from the requested source (in this case an in-memory
29      * data object passed to the constructor), read the data object into
30      * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
31      * process that block using the passed callback.
32      * @param {Object} params This parameter is not used by the MemoryProxy class.
33      * @param {Roo.data.DataReader} reader The Reader object which converts the data
34      * object into a block of Roo.data.Records.
35      * @param {Function} callback The function into which to pass the block of Roo.data.records.
36      * The function must be passed <ul>
37      * <li>The Record block object</li>
38      * <li>The "arg" argument from the load function</li>
39      * <li>A boolean success indicator</li>
40      * </ul>
41      * @param {Object} scope The scope in which to call the callback
42      * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
43      */
44     load : function(params, reader, callback, scope, arg){
45         params = params || {};
46         var result;
47         try {
48             result = reader.readRecords(this.data);
49         }catch(e){
50             this.fireEvent("loadexception", this, arg, null, e);
51             callback.call(scope, null, arg, false);
52             return;
53         }
54         callback.call(scope, result, arg, true);
55     },
56     
57     // private
58     update : function(params, records){
59         
60     }
61 });