Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/ext/pkgs/data-json-debug.js @ 77

Revision 76, 25.5 KB checked in by djay, 13 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*!
2 * Ext JS Library 3.4.0
3 * Copyright(c) 2006-2011 Sencha Inc.
4 * licensing@sencha.com
5 * http://www.sencha.com/license
6 */
7/**
8 * @class Ext.data.JsonWriter
9 * @extends Ext.data.DataWriter
10 * DataWriter extension for writing an array or single {@link Ext.data.Record} object(s) in preparation for executing a remote CRUD action.
11 */
12Ext.data.JsonWriter = Ext.extend(Ext.data.DataWriter, {
13    /**
14     * @cfg {Boolean} encode <p><tt>true</tt> to {@link Ext.util.JSON#encode JSON encode} the
15     * {@link Ext.data.DataWriter#toHash hashed data} into a standard HTTP parameter named after this
16     * Reader's <code>meta.root</code> property which, by default is imported from the associated Reader. Defaults to <tt>true</tt>.</p>
17     * <p>If set to <code>false</code>, the hashed data is {@link Ext.util.JSON#encode JSON encoded}, along with
18     * the associated {@link Ext.data.Store}'s {@link Ext.data.Store#baseParams baseParams}, into the POST body.</p>
19     * <p>When using {@link Ext.data.DirectProxy}, set this to <tt>false</tt> since Ext.Direct.JsonProvider will perform
20     * its own json-encoding.  In addition, if you're using {@link Ext.data.HttpProxy}, setting to <tt>false</tt>
21     * will cause HttpProxy to transmit data using the <b>jsonData</b> configuration-params of {@link Ext.Ajax#request}
22     * instead of <b>params</b>.</p>
23     * <p>When using a {@link Ext.data.Store#restful} Store, some serverside frameworks are
24     * tuned to expect data through the jsonData mechanism.  In those cases, one will want to set <b>encode: <tt>false</tt></b>, as in
25     * let the lower-level connection object (eg: Ext.Ajax) do the encoding.</p>
26     */
27    encode : true,
28    /**
29     * @cfg {Boolean} encodeDelete False to send only the id to the server on delete, true to encode it in an object
30     * literal, eg: <pre><code>
31{id: 1}
32 * </code></pre> Defaults to <tt>false</tt>
33     */
34    encodeDelete: false,
35   
36    constructor : function(config){
37        Ext.data.JsonWriter.superclass.constructor.call(this, config);   
38    },
39
40    /**
41     * <p>This method should not need to be called by application code, however it may be useful on occasion to
42     * override it, or augment it with an {@link Function#createInterceptor interceptor} or {@link Function#createSequence sequence}.</p>
43     * <p>The provided implementation encodes the serialized data representing the Store's modified Records into the Ajax request's
44     * <code>params</code> according to the <code>{@link #encode}</code> setting.</p>
45     * @param {Object} Ajax request params object to write into.
46     * @param {Object} baseParams as defined by {@link Ext.data.Store#baseParams}.  The baseParms must be encoded by the extending class, eg: {@link Ext.data.JsonWriter}, {@link Ext.data.XmlWriter}.
47     * @param {Object/Object[]} data Data object representing the serialized modified records from the Store. May be either a single object,
48     * or an Array of objects - user implementations must handle both cases.
49     */
50    render : function(params, baseParams, data) {
51        if (this.encode === true) {
52            // Encode here now.
53            Ext.apply(params, baseParams);
54            params[this.meta.root] = Ext.encode(data);
55        } else {
56            // defer encoding for some other layer, probably in {@link Ext.Ajax#request}.  Place everything into "jsonData" key.
57            var jdata = Ext.apply({}, baseParams);
58            jdata[this.meta.root] = data;
59            params.jsonData = jdata;
60        }
61    },
62    /**
63     * Implements abstract Ext.data.DataWriter#createRecord
64     * @protected
65     * @param {Ext.data.Record} rec
66     * @return {Object}
67     */
68    createRecord : function(rec) {
69       return this.toHash(rec);
70    },
71    /**
72     * Implements abstract Ext.data.DataWriter#updateRecord
73     * @protected
74     * @param {Ext.data.Record} rec
75     * @return {Object}
76     */
77    updateRecord : function(rec) {
78        return this.toHash(rec);
79
80    },
81    /**
82     * Implements abstract Ext.data.DataWriter#destroyRecord
83     * @protected
84     * @param {Ext.data.Record} rec
85     * @return {Object}
86     */
87    destroyRecord : function(rec){
88        if(this.encodeDelete){
89            var data = {};
90            data[this.meta.idProperty] = rec.id;
91            return data;
92        }else{
93            return rec.id;
94        }
95    }
96});/**
97 * @class Ext.data.JsonReader
98 * @extends Ext.data.DataReader
99 * <p>Data reader class to create an Array of {@link Ext.data.Record} objects
100 * from a JSON packet based on mappings in a provided {@link Ext.data.Record}
101 * constructor.</p>
102 * <p>Example code:</p>
103 * <pre><code>
104var myReader = new Ext.data.JsonReader({
105    // metadata configuration options:
106    {@link #idProperty}: 'id'
107    {@link #root}: 'rows',
108    {@link #totalProperty}: 'results',
109    {@link Ext.data.DataReader#messageProperty}: "msg"  // The element within the response that provides a user-feedback message (optional)
110
111    // the fields config option will internally create an {@link Ext.data.Record}
112    // constructor that provides mapping for reading the record data objects
113    {@link Ext.data.DataReader#fields fields}: [
114        // map Record&#39;s 'firstname' field to data object&#39;s key of same name
115        {name: 'name', mapping: 'firstname'},
116        // map Record&#39;s 'job' field to data object&#39;s 'occupation' key
117        {name: 'job', mapping: 'occupation'}
118    ]
119});
120</code></pre>
121 * <p>This would consume a JSON data object of the form:</p><pre><code>
122{
123    results: 2000, // Reader&#39;s configured {@link #totalProperty}
124    rows: [        // Reader&#39;s configured {@link #root}
125        // record data objects:
126        { {@link #idProperty id}: 1, firstname: 'Bill', occupation: 'Gardener' },
127        { {@link #idProperty id}: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
128        ...
129    ]
130}
131</code></pre>
132 * <p><b><u>Automatic configuration using metaData</u></b></p>
133 * <p>It is possible to change a JsonReader's metadata at any time by including
134 * a <b><tt>metaData</tt></b> property in the JSON data object. If the JSON data
135 * object has a <b><tt>metaData</tt></b> property, a {@link Ext.data.Store Store}
136 * object using this Reader will reconfigure itself to use the newly provided
137 * field definition and fire its {@link Ext.data.Store#metachange metachange}
138 * event. The metachange event handler may interrogate the <b><tt>metaData</tt></b>
139 * property to perform any configuration required.</p>
140 * <p>Note that reconfiguring a Store potentially invalidates objects which may
141 * refer to Fields or Records which no longer exist.</p>
142 * <p>To use this facility you would create the JsonReader like this:</p><pre><code>
143var myReader = new Ext.data.JsonReader();
144</code></pre>
145 * <p>The first data packet from the server would configure the reader by
146 * containing a <b><tt>metaData</tt></b> property <b>and</b> the data. For
147 * example, the JSON data object might take the form:</p><pre><code>
148{
149    metaData: {
150        "{@link #idProperty}": "id",
151        "{@link #root}": "rows",
152        "{@link #totalProperty}": "results"
153        "{@link #successProperty}": "success",
154        "{@link Ext.data.DataReader#fields fields}": [
155            {"name": "name"},
156            {"name": "job", "mapping": "occupation"}
157        ],
158        // used by store to set its sortInfo
159        "sortInfo":{
160           "field": "name",
161           "direction": "ASC"
162        },
163        // {@link Ext.PagingToolbar paging data} (if applicable)
164        "start": 0,
165        "limit": 2,
166        // custom property
167        "foo": "bar"
168    },
169    // Reader&#39;s configured {@link #successProperty}
170    "success": true,
171    // Reader&#39;s configured {@link #totalProperty}
172    "results": 2000,
173    // Reader&#39;s configured {@link #root}
174    // (this data simulates 2 results {@link Ext.PagingToolbar per page})
175    "rows": [ // <b>*Note:</b> this must be an Array
176        { "id": 1, "name": "Bill", "occupation": "Gardener" },
177        { "id": 2, "name":  "Ben", "occupation": "Horticulturalist" }
178    ]
179}
180 * </code></pre>
181 * <p>The <b><tt>metaData</tt></b> property in the JSON data object should contain:</p>
182 * <div class="mdetail-params"><ul>
183 * <li>any of the configuration options for this class</li>
184 * <li>a <b><tt>{@link Ext.data.Record#fields fields}</tt></b> property which
185 * the JsonReader will use as an argument to the
186 * {@link Ext.data.Record#create data Record create method} in order to
187 * configure the layout of the Records it will produce.</li>
188 * <li>a <b><tt>{@link Ext.data.Store#sortInfo sortInfo}</tt></b> property
189 * which the JsonReader will use to set the {@link Ext.data.Store}'s
190 * {@link Ext.data.Store#sortInfo sortInfo} property</li>
191 * <li>any custom properties needed</li>
192 * </ul></div>
193 *
194 * @constructor
195 * Create a new JsonReader
196 * @param {Object} meta Metadata configuration options.
197 * @param {Array/Object} recordType
198 * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which
199 * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}
200 * constructor created from {@link Ext.data.Record#create}.</p>
201 */
202Ext.data.JsonReader = function(meta, recordType){
203    meta = meta || {};
204    /**
205     * @cfg {String} idProperty [id] Name of the property within a row object
206     * that contains a record identifier value.  Defaults to <tt>id</tt>
207     */
208    /**
209     * @cfg {String} successProperty [success] Name of the property from which to
210     * retrieve the success attribute. Defaults to <tt>success</tt>.  See
211     * {@link Ext.data.DataProxy}.{@link Ext.data.DataProxy#exception exception}
212     * for additional information.
213     */
214    /**
215     * @cfg {String} totalProperty [total] Name of the property from which to
216     * retrieve the total number of records in the dataset. This is only needed
217     * if the whole dataset is not passed in one go, but is being paged from
218     * the remote server.  Defaults to <tt>total</tt>.
219     */
220    /**
221     * @cfg {String} root [undefined] <b>Required</b>.  The name of the property
222     * which contains the Array of row objects.  Defaults to <tt>undefined</tt>.
223     * An exception will be thrown if the root property is undefined. The data
224     * packet value for this property should be an empty array to clear the data
225     * or show no data.
226     */
227    Ext.applyIf(meta, {
228        idProperty: 'id',
229        successProperty: 'success',
230        totalProperty: 'total'
231    });
232
233    Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
234};
235Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
236    /**
237     * This JsonReader's metadata as passed to the constructor, or as passed in
238     * the last data packet's <b><tt>metaData</tt></b> property.
239     * @type Mixed
240     * @property meta
241     */
242    /**
243     * This method is only used by a DataProxy which has retrieved data from a remote server.
244     * @param {Object} response The XHR object which contains the JSON data in its responseText.
245     * @return {Object} data A data block which is used by an Ext.data.Store object as
246     * a cache of Ext.data.Records.
247     */
248    read : function(response){
249        var json = response.responseText;
250        var o = Ext.decode(json);
251        if(!o) {
252            throw {message: 'JsonReader.read: Json object not found'};
253        }
254        return this.readRecords(o);
255    },
256
257    /*
258     * TODO: refactor code between JsonReader#readRecords, #readResponse into 1 method.
259     * there's ugly duplication going on due to maintaining backwards compat. with 2.0.  It's time to do this.
260     */
261    /**
262     * Decode a JSON response from server.
263     * @param {String} action [Ext.data.Api.actions.create|read|update|destroy]
264     * @param {Object} response The XHR object returned through an Ajax server request.
265     * @return {Response} A {@link Ext.data.Response Response} object containing the data response, and also status information.
266     */
267    readResponse : function(action, response) {
268        var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
269        if(!o) {
270            throw new Ext.data.JsonReader.Error('response');
271        }
272
273        var root = this.getRoot(o),
274            success = this.getSuccess(o);
275        if (success && action === Ext.data.Api.actions.create) {
276            var def = Ext.isDefined(root);
277            if (def && Ext.isEmpty(root)) {
278                throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
279            }
280            else if (!def) {
281                throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
282            }
283        }
284
285        // instantiate response object
286        var res = new Ext.data.Response({
287            action: action,
288            success: success,
289            data: (root) ? this.extractData(root, false) : [],
290            message: this.getMessage(o),
291            raw: o
292        });
293
294        // blow up if no successProperty
295        if (Ext.isEmpty(res.success)) {
296            throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
297        }
298        return res;
299    },
300
301    /**
302     * Create a data block containing Ext.data.Records from a JSON object.
303     * @param {Object} o An object which contains an Array of row objects in the property specified
304     * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
305     * which contains the total size of the dataset.
306     * @return {Object} data A data block which is used by an Ext.data.Store object as
307     * a cache of Ext.data.Records.
308     */
309    readRecords : function(o){
310        /**
311         * After any data loads, the raw JSON data is available for further custom processing.  If no data is
312         * loaded or there is a load exception this property will be undefined.
313         * @type Object
314         */
315        this.jsonData = o;
316        if(o.metaData){
317            this.onMetaChange(o.metaData);
318        }
319        var s = this.meta, Record = this.recordType,
320            f = Record.prototype.fields, fi = f.items, fl = f.length, v;
321
322        var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
323        if(s.totalProperty){
324            v = parseInt(this.getTotal(o), 10);
325            if(!isNaN(v)){
326                totalRecords = v;
327            }
328        }
329        if(s.successProperty){
330            v = this.getSuccess(o);
331            if(v === false || v === 'false'){
332                success = false;
333            }
334        }
335
336        // TODO return Ext.data.Response instance instead.  @see #readResponse
337        return {
338            success : success,
339            records : this.extractData(root, true), // <-- true to return [Ext.data.Record]
340            totalRecords : totalRecords
341        };
342    },
343
344    // private
345    buildExtractors : function() {
346        if(this.ef){
347            return;
348        }
349        var s = this.meta, Record = this.recordType,
350            f = Record.prototype.fields, fi = f.items, fl = f.length;
351
352        if(s.totalProperty) {
353            this.getTotal = this.createAccessor(s.totalProperty);
354        }
355        if(s.successProperty) {
356            this.getSuccess = this.createAccessor(s.successProperty);
357        }
358        if (s.messageProperty) {
359            this.getMessage = this.createAccessor(s.messageProperty);
360        }
361        this.getRoot = s.root ? this.createAccessor(s.root) : function(p){return p;};
362        if (s.id || s.idProperty) {
363            var g = this.createAccessor(s.id || s.idProperty);
364            this.getId = function(rec) {
365                var r = g(rec);
366                return (r === undefined || r === '') ? null : r;
367            };
368        } else {
369            this.getId = function(){return null;};
370        }
371        var ef = [];
372        for(var i = 0; i < fl; i++){
373            f = fi[i];
374            var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
375            ef.push(this.createAccessor(map));
376        }
377        this.ef = ef;
378    },
379
380    /**
381     * @ignore
382     * TODO This isn't used anywhere??  Don't we want to use this where possible instead of complex #createAccessor?
383     */
384    simpleAccess : function(obj, subsc) {
385        return obj[subsc];
386    },
387
388    /**
389     * @ignore
390     */
391    createAccessor : function(){
392        var re = /[\[\.]/;
393        return function(expr) {
394            if(Ext.isEmpty(expr)){
395                return Ext.emptyFn;
396            }
397            if(Ext.isFunction(expr)){
398                return expr;
399            }
400            var i = String(expr).search(re);
401            if(i >= 0){
402                return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
403            }
404            return function(obj){
405                return obj[expr];
406            };
407
408        };
409    }(),
410
411    /**
412     * type-casts a single row of raw-data from server
413     * @param {Object} data
414     * @param {Array} items
415     * @param {Integer} len
416     * @private
417     */
418    extractValues : function(data, items, len) {
419        var f, values = {};
420        for(var j = 0; j < len; j++){
421            f = items[j];
422            var v = this.ef[j](data);
423            values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
424        }
425        return values;
426    }
427});
428
429/**
430 * @class Ext.data.JsonReader.Error
431 * Error class for JsonReader
432 */
433Ext.data.JsonReader.Error = Ext.extend(Ext.Error, {
434    constructor : function(message, arg) {
435        this.arg = arg;
436        Ext.Error.call(this, message);
437    },
438    name : 'Ext.data.JsonReader'
439});
440Ext.apply(Ext.data.JsonReader.Error.prototype, {
441    lang: {
442        'response': 'An error occurred while json-decoding your server response',
443        'successProperty-response': 'Could not locate your "successProperty" in your server response.  Please review your JsonReader config to ensure the config-property "successProperty" matches the property in your server-response.  See the JsonReader docs.',
444        'root-undefined-config': 'Your JsonReader was configured without a "root" property.  Please review your JsonReader config and make sure to define the root property.  See the JsonReader docs.',
445        'idProperty-undefined' : 'Your JsonReader was configured without an "idProperty"  Please review your JsonReader configuration and ensure the "idProperty" is set (e.g.: "id").  See the JsonReader docs.',
446        'root-empty': 'Data was expected to be returned by the server in the "root" property of the response.  Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response.  See JsonReader docs.'
447    }
448});
449/**
450 * @class Ext.data.ArrayReader
451 * @extends Ext.data.JsonReader
452 * <p>Data reader class to create an Array of {@link Ext.data.Record} objects from an Array.
453 * Each element of that Array represents a row of data fields. The
454 * fields are pulled into a Record object using as a subscript, the <code>mapping</code> property
455 * of the field definition if it exists, or the field's ordinal position in the definition.</p>
456 * <p>Example code:</p>
457 * <pre><code>
458var Employee = Ext.data.Record.create([
459    {name: 'name', mapping: 1},         // "mapping" only needed if an "id" field is present which
460    {name: 'occupation', mapping: 2}    // precludes using the ordinal position as the index.
461]);
462var myReader = new Ext.data.ArrayReader({
463    {@link #idIndex}: 0
464}, Employee);
465</code></pre>
466 * <p>This would consume an Array like this:</p>
467 * <pre><code>
468[ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
469 * </code></pre>
470 * @constructor
471 * Create a new ArrayReader
472 * @param {Object} meta Metadata configuration options.
473 * @param {Array/Object} recordType
474 * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which
475 * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}
476 * constructor created from {@link Ext.data.Record#create}.</p>
477 */
478Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
479    /**
480     * @cfg {String} successProperty
481     * @hide
482     */
483    /**
484     * @cfg {Number} id (optional) The subscript within row Array that provides an ID for the Record.
485     * Deprecated. Use {@link #idIndex} instead.
486     */
487    /**
488     * @cfg {Number} idIndex (optional) The subscript within row Array that provides an ID for the Record.
489     */
490    /**
491     * Create a data block containing Ext.data.Records from an Array.
492     * @param {Object} o An Array of row objects which represents the dataset.
493     * @return {Object} data A data block which is used by an Ext.data.Store object as
494     * a cache of Ext.data.Records.
495     */
496    readRecords : function(o){
497        this.arrayData = o;
498        var s = this.meta,
499            sid = s ? Ext.num(s.idIndex, s.id) : null,
500            recordType = this.recordType,
501            fields = recordType.prototype.fields,
502            records = [],
503            success = true,
504            v;
505
506        var root = this.getRoot(o);
507
508        for(var i = 0, len = root.length; i < len; i++) {
509            var n = root[i],
510                values = {},
511                id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
512            for(var j = 0, jlen = fields.length; j < jlen; j++) {
513                var f = fields.items[j],
514                    k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
515                v = n[k] !== undefined ? n[k] : f.defaultValue;
516                v = f.convert(v, n);
517                values[f.name] = v;
518            }
519            var record = new recordType(values, id);
520            record.json = n;
521            records[records.length] = record;
522        }
523
524        var totalRecords = records.length;
525
526        if(s.totalProperty) {
527            v = parseInt(this.getTotal(o), 10);
528            if(!isNaN(v)) {
529                totalRecords = v;
530            }
531        }
532        if(s.successProperty){
533            v = this.getSuccess(o);
534            if(v === false || v === 'false'){
535                success = false;
536            }
537        }
538
539        return {
540            success : success,
541            records : records,
542            totalRecords : totalRecords
543        };
544    }
545});/**
546 * @class Ext.data.ArrayStore
547 * @extends Ext.data.Store
548 * <p>Formerly known as "SimpleStore".</p>
549 * <p>Small helper class to make creating {@link Ext.data.Store}s from Array data easier.
550 * An ArrayStore will be automatically configured with a {@link Ext.data.ArrayReader}.</p>
551 * <p>A store configuration would be something like:<pre><code>
552var store = new Ext.data.ArrayStore({
553    // store configs
554    autoDestroy: true,
555    storeId: 'myStore',
556    // reader configs
557    idIndex: 0, 
558    fields: [
559       'company',
560       {name: 'price', type: 'float'},
561       {name: 'change', type: 'float'},
562       {name: 'pctChange', type: 'float'},
563       {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
564    ]
565});
566 * </code></pre></p>
567 * <p>This store is configured to consume a returned object of the form:<pre><code>
568var myData = [
569    ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
570    ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
571    ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
572    ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
573    ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
574];
575 * </code></pre>
576 * An object literal of this form could also be used as the {@link #data} config option.</p>
577 * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
578 * <b>{@link Ext.data.ArrayReader ArrayReader}</b>.</p>
579 * @constructor
580 * @param {Object} config
581 * @xtype arraystore
582 */
583Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
584    /**
585     * @cfg {Ext.data.DataReader} reader @hide
586     */
587    constructor: function(config){
588        Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
589            reader: new Ext.data.ArrayReader(config)
590        }));
591    },
592
593    loadData : function(data, append){
594        if(this.expandData === true){
595            var r = [];
596            for(var i = 0, len = data.length; i < len; i++){
597                r[r.length] = [data[i]];
598            }
599            data = r;
600        }
601        Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
602    }
603});
604Ext.reg('arraystore', Ext.data.ArrayStore);
605
606// backwards compat
607Ext.data.SimpleStore = Ext.data.ArrayStore;
608Ext.reg('simplestore', Ext.data.SimpleStore);/**
609 * @class Ext.data.JsonStore
610 * @extends Ext.data.Store
611 * <p>Small helper class to make creating {@link Ext.data.Store}s from JSON data easier.
612 * A JsonStore will be automatically configured with a {@link Ext.data.JsonReader}.</p>
613 * <p>A store configuration would be something like:<pre><code>
614var store = new Ext.data.JsonStore({
615    // store configs
616    autoDestroy: true,
617    url: 'get-images.php',
618    storeId: 'myStore',
619    // reader configs
620    root: 'images',
621    idProperty: 'name',
622    fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
623});
624 * </code></pre></p>
625 * <p>This store is configured to consume a returned object of the form:<pre><code>
626{
627    images: [
628        {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
629        {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
630    ]
631}
632 * </code></pre>
633 * An object literal of this form could also be used as the {@link #data} config option.</p>
634 * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
635 * <b>{@link Ext.data.JsonReader JsonReader}</b>.</p>
636 * @constructor
637 * @param {Object} config
638 * @xtype jsonstore
639 */
640Ext.data.JsonStore = Ext.extend(Ext.data.Store, {
641    /**
642     * @cfg {Ext.data.DataReader} reader @hide
643     */
644    constructor: function(config){
645        Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
646            reader: new Ext.data.JsonReader(config)
647        }));
648    }
649});
650Ext.reg('jsonstore', Ext.data.JsonStore);
Note: See TracBrowser for help on using the repository browser.