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/GeoExt/lib/GeoExt/plugins/AttributeForm.js @ 76

Revision 76, 4.1 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/**
2 * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
3 *
4 * Published under the BSD license.
5 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6 * of the license.
7 */
8
9/*
10 * @include GeoExt/widgets/form.js
11 */
12
13Ext.namespace("GeoExt.plugins");
14
15/** api: (define)
16 *  module = GeoExt.plugins
17 *  class = AttributeForm
18 */
19
20/** api: example
21 *  Sample code showing how to use an Ext form panel as a feature
22 *  attribute form (for editing features for example).
23 *
24 *  .. code-block:: javascript
25 *
26 *      var formPanel = new Ext.form.FormPanel({
27 *          autoScroll: true,
28 *          height: 300,
29 *          width: 350,
30 *          defaults: {
31 *              maxLengthText: "too long",
32 *              minLengthText: "too short"
33 *          }
34 *          plugins: [
35 *              new GeoExt.plugins.AttributeForm({
36 *                  attributeStore: new GeoExt.data.AttributeStore({
37 *                      url: "http://some.wfs",
38 *                      baseParams: {
39 *                          "SERVICE": "WFS",
40 *                          "VERSION": "1.1.0",
41 *                          "REQUEST": "DescribeFeatureType",
42 *                          "TYPENAME": "the_typename"
43 *                      }
44 *                  })
45 *              })
46 *          ]
47 *      });
48 */
49
50/** api: constructor
51 *  .. class:: AttributeForm
52 *
53 *  This plugin allows creating form items from attribute records
54 *  and fill a form panel with these items.
55 */
56
57GeoExt.plugins.AttributeForm = function(config) {
58    Ext.apply(this, config);
59};
60
61GeoExt.plugins.AttributeForm.prototype = {
62
63    /** api: config[attributeStore]
64     *  ``Ext.data.Store`` The attribute store to bind to this plugin.
65     *  It can be any Ext store configured with a
66     *  :class:`GeoExt.data.AttributeReader`. If set form items
67     *  will be created from the attribute records in the form. In
68     *  most cases this store will be a :class:`GeoExt.data.AttributeStore`.
69     */
70    /** private: property[attributeStore]
71     *  ``Ext.data.Store`` The attribute store.
72     */
73    attributeStore: null,
74
75    /** private: property[formPanel]
76     *  ``Ext.form.FormPanel`` This form panel.
77     */
78    formPanel: null,
79
80    /** private: method[init]
81     *  :param formPanel: class:`Ext.form.FormPanel`
82     *
83     *  Initializes the plugin.
84     */
85    init: function(formPanel) {
86        this.formPanel = formPanel;
87        if(this.attributeStore instanceof Ext.data.Store) {
88            this.fillForm();
89            this.bind(this.attributeStore);
90        }
91        formPanel.on("destroy", this.onFormDestroy, this);
92    },
93
94    /** private: method[bind]
95     *  :param store: ``Ext.data.Store`` The attribute store this form panel
96     *  is to be bound to.
97     *
98     *  Bind the panel to the attribute store passed as a parameter.
99     */
100    bind: function(store) {
101        this.unbind();
102        store.on({
103            "load": this.onLoad,
104            scope: this
105        });
106        this.attributeStore = store;
107    },
108
109    /** private: method[unbind]
110     *
111     *  Unbind the panel from the attribute store it is currently bound
112     *  to, if any.
113     */
114    unbind: function() {
115        if(this.attributeStore) {
116            this.attributeStore.un("load", this.onLoad, this);
117        }
118    },
119
120    /** private: method[onLoad]
121     *
122     *  Callback called when the store is loaded.
123     */
124    onLoad: function() {
125        if(this.formPanel.items) {
126            this.formPanel.removeAll();
127        }
128        this.fillForm();
129    },
130
131    /** private: method[fillForm]
132     *
133     *  For each attribute record in the attribute store create
134     *  a form field and add it to the form.
135     */
136    fillForm: function() {
137        this.attributeStore.each(function(record) {
138            var field = GeoExt.form.recordToField(record);
139            if(field) {
140                this.formPanel.add(field);
141            }
142        }, this);
143        this.formPanel.doLayout();
144    },
145
146    /** private: method[onFormDestroy]
147     */
148    onFormDestroy: function() {
149        this.unbind();
150    }
151};
152
153/** api: ptype = gx_attributeform */
154Ext.preg("gx_attributeform", GeoExt.plugins.AttributeForm);
Note: See TracBrowser for help on using the repository browser.