Skip to content

Commit d11f6d7

Browse files
committed
Document QGIS FeatureSearch with dynamic select options
1 parent 635a9b5 commit d11f6d7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/topics/Search.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,23 @@ A more complex form, useable through the [`FeatureSearch`](../references/qwc2_pl
230230
}
231231
```
232232

233-
Here, each field will provide a value which is substituted in the expression. Any [HTML Input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) type is supported (i.e. `text`, `number`, `range`, ...), with options depending on the input type. In addition, the `select` field type is supported to display a ComboBox, with the entries provided as `options` as in the example above. It is also possible to pass a flat list as `options`, i.e. `["Female", "Male"]` if the value is equal to the label.
233+
Here, each field will provide a value which is substituted in the expression. Any [HTML Input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) type is supported (i.e. `text`, `number`, `range`, ...), with options depending on the input type.
234+
235+
In addition, the `select` field type is supported to display a ComboBox. You can specify the options:
236+
237+
* As a `[{"value": "<value>", "label": "<label>"}, ...]` value-label list.
238+
* As a flat `["<value1>", "<value2>", ...]` list, in which case value and label are equal.
239+
* By specifying a dynamic lookup URL as `options_query` instead of `options`, as follows:
240+
241+
* You can query the options via `qwc-data-service` by setting `options_query` to `<data_service_url>/<dataset>/keyvals?key=<key_field>&value=<value_field>`.
242+
* In addition, you can pass a filter to dynamically query the key-values depending on the value of another field by specifying `filter`, i.e. `<data_service_url>/<dataset>/keyvals?key=<key_field>&value=<value_field>&filter=[["<field>","=","$FIELDNAME$"]]`, where `$FIELDNAME$` will be replaced by the currently selected value for field `FIELDNAME`.
243+
* Alternatively, you can also query any service (including the `qwc-data-service`, or a WFS/OAPIF service) which returns a GeoJSON Feature Collection by specifying `options_query`, `value_field` and `label_field`, in which case the options will be populated with the unique sets of `{"<value_field>": "<label_field>"`} extracted from the returned GeoJSON features. For example:
244+
```
245+
"type": "select",
246+
"options_query": "http://<data_service_url>/<dataset>?fields=<value_field>,<label_field>&filter=[[\"<otherfield>\",\"=\",\"$FIELDNAME$\"]]",
247+
"value_field": "<value_field>",
248+
"label_field": "<label_field>"
249+
```
234250
235251
*Note*: `qgis` provider searches are exposed to the search field only if no `fields` are specified (i.e. single input search). The `FeatureSearch` plugin on the other hand will list all `qgis` provider searches.
236252

0 commit comments

Comments
 (0)