source: sandbox/opengeo/geoexplorer/lib/GeoExt/data/LayerRecord.js @ 264

Last change on this file since 264 was 264, checked in by tschaub, 9 years ago

merge r246:HEAD from trunk

File size: 1.5 KB
Line 
1/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation
2 * Published under the BSD license.
3 * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
4 * of the license.
5 *
6 * pending approval */
7
8Ext.namespace("GeoExt.data");
9
10/**
11 * Class: GeoExt.data.LayerRecord
12 * A subclass of {Ext.data.Record} which provides a special record that
13 * represents an {OpenLayers.Layer}. This record will always have at least a
14 * layer and a title field in its data. The id of this record will be the same
15 * as the id of the layer it represents.
16 *
17 * Inherits from
18 * - {Ext.data.Record}
19 */
20GeoExt.data.LayerRecord = Ext.data.Record.create([
21    {name: "layer"},
22    {name: "title", type: "string", mapping: "name"}
23]);
24
25/**
26 * APIFunction: GeoExt.data.LayerRecord.create
27 * Creates a constructor for a LayerRecord, optionally with additional
28 * fields.
29 *
30 * Parameters:
31 * o - {Array} Field definition as in {Ext.data.Record.create}. Can be omitted
32 *     if no additional fields are required (records will always have a
33 *     {OpenLayers.Layer} layer and a {String} title field).
34 *
35 * Returns:
36 * {Function} A specialized {<GeoExt.data.LayerRecord>} constructor.
37 */
38GeoExt.data.LayerRecord.create = function(o) {
39    var f = Ext.extend(GeoExt.data.LayerRecord, {});
40    var p = f.prototype;
41    if(o) {
42        for(var i = 0, len = o.length; i < len; i++){
43            p.fields.add(new Ext.data.Field(o[i]));
44        }
45    }
46    return f;
47}
Note: See TracBrowser for help on using the repository browser.