1 | |
---|
2 | .. currentmodule:: GeoExt.form |
---|
3 | |
---|
4 | :class:`GeoExt.form.SearchAction` |
---|
5 | ================================================================================ |
---|
6 | |
---|
7 | |
---|
8 | .. cssclass:: meta |
---|
9 | |
---|
10 | |
---|
11 | Extends |
---|
12 | * `Ext.form.Action <http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Action>`_ |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | .. class:: SearchAction(form, options) |
---|
21 | |
---|
22 | A specific ``Ext.form.Action`` to be used when using a form to do |
---|
23 | trigger search requests througn an ``OpenLayers.Protocol``. |
---|
24 | |
---|
25 | Arguments: |
---|
26 | |
---|
27 | * form ``Ext.form.BasicForm`` A basic form instance. |
---|
28 | * options ``Object`` Options passed to the protocol'read method |
---|
29 | One can add an abortPrevious property to these options, if set |
---|
30 | to true, the abort method will be called on the protocol if |
---|
31 | there's a pending request. |
---|
32 | |
---|
33 | When run this action builds an ``OpenLayers.Filter`` from the form |
---|
34 | and passes this filter to its protocol's read method. The form fields |
---|
35 | must be named after a specific convention, so that an appropriate |
---|
36 | ``OpenLayers.Filter.Comparison`` filter is created for each |
---|
37 | field. |
---|
38 | |
---|
39 | For example a field with the name ``foo__like`` would result in an |
---|
40 | ``OpenLayers.Filter.Comparison`` of type |
---|
41 | ``OpenLayers.Filter.Comparison.LIKE`` being created. |
---|
42 | |
---|
43 | Here is the convention: |
---|
44 | |
---|
45 | * ``<name>__eq: OpenLayers.Filter.Comparison.EQUAL_TO`` |
---|
46 | * ``<name>__ne: OpenLayers.Filter.Comparison.NOT_EQUAL_TO`` |
---|
47 | * ``<name>__lt: OpenLayers.Filter.Comparison.LESS_THAN`` |
---|
48 | * ``<name>__le: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO`` |
---|
49 | * ``<name>__gt: OpenLayers.Filter.Comparison.GREATER_THAN`` |
---|
50 | * ``<name>__ge: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO`` |
---|
51 | * ``<name>__like: OpenLayers.Filter.Comparison.LIKE`` |
---|
52 | |
---|
53 | In most cases your would not directly create ``GeoExt.form.SearchAction`` |
---|
54 | objects, but use :class:`GeoExt.form.FormPanel` instead. |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | Example Use |
---|
59 | ----------- |
---|
60 | |
---|
61 | Sample code showing how to use a GeoExt SearchAction with an Ext form panel: |
---|
62 | |
---|
63 | .. code-block:: javascript |
---|
64 | |
---|
65 | var formPanel = new Ext.form.Panel({ |
---|
66 | renderTo: "formpanel", |
---|
67 | items: [{ |
---|
68 | xtype: "textfield", |
---|
69 | name: "name__like", |
---|
70 | value: "mont" |
---|
71 | }, { |
---|
72 | xtype: "textfield", |
---|
73 | name: "elevation__ge", |
---|
74 | value: "2000" |
---|
75 | }] |
---|
76 | }); |
---|
77 | |
---|
78 | var searchAction = new GeoExt.form.SearchAction(formPanel.getForm(), { |
---|
79 | protocol: new OpenLayers.Protocol.WFS({ |
---|
80 | url: "http://publicus.opengeo.org/geoserver/wfs", |
---|
81 | featureType: "tasmania_roads", |
---|
82 | featureNS: "http://www.openplans.org/topp" |
---|
83 | }), |
---|
84 | abortPrevious: true |
---|
85 | }); |
---|
86 | |
---|
87 | formPanel.getForm().doAction(searchAction, { |
---|
88 | callback: function(response) { |
---|
89 | // response.features includes the features read |
---|
90 | // from the server through the protocol |
---|
91 | } |
---|
92 | }); |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | Public Properties |
---|
100 | ----------------- |
---|
101 | |
---|
102 | Public properties in addition to those |
---|
103 | listed for `Ext.form.Action <http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Action>`_. |
---|
104 | |
---|
105 | |
---|
106 | .. attribute:: SearchAction.response |
---|
107 | |
---|
108 | ``OpenLayers.Protocol.Response`` A reference to the response |
---|
109 | resulting from the search request. Read-only. |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|