initial import
[roojs1] / Roo / data / DataReader.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 // Base class for reading structured data from a data source.  This class is intended to be
13 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
14
15 /**
16  * @class Roo.data.DataReader
17  * Base class for reading structured data from a data source.  This class is intended to be
18  * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
19  */
20
21 Roo.data.DataReader = function(meta, recordType){
22     
23     this.meta = meta;
24     
25     this.recordType = recordType instanceof Array ? 
26         Roo.data.Record.create(recordType) : recordType;
27 };
28
29 Roo.data.DataReader.prototype = {
30      /**
31      * Create an empty record
32      * @param {Object} data (optional) - overlay some values
33      * @return {Roo.data.Record} record created.
34      */
35     newRow :  function(d) {
36         var da =  {};
37         this.recordType.prototype.fields.each(function(c) {
38             da[c.name] = '';
39         });
40         return new this.recordType(Roo.apply(da, d));
41     }
42     
43 };