1 | /** |
---|
2 | * Copyright (c) 2008-2010 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 | /** api: (define) |
---|
10 | * module = GeoExt.form |
---|
11 | * class = FormPanel |
---|
12 | * base_link = `Ext.form.FormPanel <http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_ |
---|
13 | */ |
---|
14 | |
---|
15 | /** |
---|
16 | * @include GeoExt/widgets/form/BasicForm.js |
---|
17 | */ |
---|
18 | |
---|
19 | Ext.namespace("GeoExt.form"); |
---|
20 | |
---|
21 | /** api: example |
---|
22 | * Sample code showing how to use a GeoExt form panel. |
---|
23 | * |
---|
24 | * .. code-block:: javascript |
---|
25 | * |
---|
26 | * var formPanel = new GeoExt.form.FormPanel({ |
---|
27 | * renderTo: "formpanel", |
---|
28 | * protocol: new OpenLayers.Protocol.WFS({ |
---|
29 | * url: "http://publicus.opengeo.org/geoserver/wfs", |
---|
30 | * featureType: "tasmania_roads", |
---|
31 | * featureNS: "http://www.openplans.org/topp" |
---|
32 | * }), |
---|
33 | * items: [{ |
---|
34 | * xtype: "textfield", |
---|
35 | * name: "name__ilike", |
---|
36 | * value: "mont" |
---|
37 | * }, { |
---|
38 | * xtype: "textfield", |
---|
39 | * name: "elevation__ge", |
---|
40 | * value: "2000" |
---|
41 | * }], |
---|
42 | * listeners: { |
---|
43 | * actioncomplete: function(form, action) { |
---|
44 | * // this listener triggers when the search request |
---|
45 | * // is complete, the OpenLayers.Protocol.Response |
---|
46 | * // resulting from the request is available |
---|
47 | * // in "action.response" |
---|
48 | * } |
---|
49 | * } |
---|
50 | * }); |
---|
51 | * |
---|
52 | * formPanel.addButton({ |
---|
53 | * text: "search", |
---|
54 | * handler: function() { |
---|
55 | * this.search(); |
---|
56 | * }, |
---|
57 | * scope: formPanel |
---|
58 | * }); |
---|
59 | */ |
---|
60 | |
---|
61 | /** api: constructor |
---|
62 | * .. class:: FormPanel(config) |
---|
63 | * |
---|
64 | * A specific ``Ext.form.FormPanel`` whose internal form is a |
---|
65 | * :class:`GeoExt.form.BasicForm` instead of ``Ext.form.BasicForm``. |
---|
66 | * One would use this form to do search requests through |
---|
67 | * an ``OpenLayers.Protocol`` object (``OpenLayers.Protocol.WFS`` |
---|
68 | * for example). |
---|
69 | * |
---|
70 | * Look at :class:`GeoExt.form.SearchAction` to understand how |
---|
71 | * form fields must be named for appropriate filters to be |
---|
72 | * passed to the protocol. |
---|
73 | */ |
---|
74 | GeoExt.form.FormPanel = Ext.extend(Ext.form.FormPanel, { |
---|
75 | /** api: config[protocol] |
---|
76 | * ``OpenLayers.Protocol`` The protocol instance this form panel |
---|
77 | * is configured with, actions resulting from this form |
---|
78 | * will be performed through the protocol. |
---|
79 | */ |
---|
80 | protocol: null, |
---|
81 | |
---|
82 | /** private: method[createForm] |
---|
83 | * Create the internal :class:`GeoExt.form.BasicForm` instance. |
---|
84 | */ |
---|
85 | createForm: function() { |
---|
86 | delete this.initialConfig.listeners; |
---|
87 | return new GeoExt.form.BasicForm(null, this.initialConfig); |
---|
88 | }, |
---|
89 | |
---|
90 | /** api: method[search] |
---|
91 | * :param options: ``Object`` The options passed to the |
---|
92 | * :class:`GeoExt.form.SearchAction` constructor. |
---|
93 | * |
---|
94 | * Shortcut to the internal form's search method. |
---|
95 | */ |
---|
96 | search: function(options) { |
---|
97 | this.getForm().search(options); |
---|
98 | } |
---|
99 | }); |
---|
100 | |
---|
101 | /** api: xtype = gx_formpanel */ |
---|
102 | Ext.reg("gx_formpanel", GeoExt.form.FormPanel); |
---|