Skip to main content
Skip table of contents

XML Editor - Auto-completion field

The auto-completion field is a widget for the XML editor that can be used as an alternative to a pop-up menu widget.

Overview

The auto-completion fields allow the selection of an entry not only by mouse or arrow keys but also by typing in a search term (word component). Additionally, it can be used for complex queries (such as asset queries).

Example search query with the Auto-completion field

Syntax

CODE
< xe:auto-completion-field source = " " search-value-source = " " internal-search = " " popup-row-height = " " popup-row-width = " " css-key = " " expression-id = " " max-items = " " >
< xe:options value-key = " " label-key = " " option-label-expression = " " lookup-expression = " " > < xe:generator expression = " " />
</ xe:options> </ xe:auto-completion-field>

Attributes

  • popup-row-height:  Height of one row in the suggestion list (popup) (optional).

  • popup-row-width:  Width of one line in the suggestion list (popup) (optional).

  • css-key:  CSS used for formatting the HTML view in the suggestion list (optional). The CSS must be available under the name specified in the file "styles.xml" .

  • expression-id:  XSLT used to generate the HTML view in the suggestion list (optional). The XSLT must be available under the specified name in the file "client-dialog-include.xml".

  • max-items:  Limits the maximum number of visible items in the suggestion list (optional).

  • label-key:  XML path to the attribute that is used to display the label (name) of a selected value. The referenced attribute is also used for the local search. It tested whether the entered term is included within this attribute value.

  • option-label-expression:  XPath formula for the calculation of a label which is used to display the entries in the suggestion list (optional). This attribute is not relevant if the formatting of the entries is done using XSLT. If the attribute is missing, the referenced name via "label-key" is displayed.

  • search-value-source:  XML path to an attribute where the search string you just entered is stored temporarily (optional). Now the value becomes available outside of the widget and can be used in the XPath formula with the generator as a parameter for the search condition.

  • internal-search:  Flag to determine whether the internal or external search is in use (optional). Possible values are: "true", and "false" (Default is "true"). If this attribute has been set to "true", the suggestion list is filtered by the widget itself. Otherwise, the widget runs in the mode "external search". In that case, the suggestion list is reloaded from the server after each input. It is mandatory that the filtering is performed by the server using the current search string in the query condition (see also: search-value-source).

  • lookup-expression:  Only for external search: XPath expression to load an option associated with a registered value (key) e.g. ID --> Asset (optional).

Examples

Example 1

Auto completion box to select a user (workflow target). Local access from the generator to the master data (Cached tables) of the client.

CODE
< xe:auto-completion-field label = "${workflow-target}" label- style =" label-default " width = "30em" 
 source = "@wf_target" sort = "ascending" >
< xe:options label-key = "@display_name" value-key = "@id" >
< xe:generator name = "filtered_cachedtables" table-name = "party" source = "@isvisible" match = "1" /> </ xe:options>
</ xe:auto-completion-field>

Example 2

Auto-completion box to select an image asset. The ID of the selected asset is written in an asset feature of the type "asset reference". The generator runs an asset query on the censhare server using an XPath query. The search is performed only once when opening the dialog. Filtering by the input value is not done on the server, instead, it will be performed by the client itself. The text inside the suggestion list is set up via an XPath formula.

CODE
< xe:auto-completion-field source = "asset_feature[feature= 'mf:asset-ref2',value_long2= '0']@value_asset_id" width = "200" max-items = "1000" >
< xe:options label-key = "@name" option-label-expression = " =:concat(asset/@name, ', ', asset/@id)" value-key = "@id" >
< xe:generator expression = " =:cs:asset()[@censhare:asset.type= 'picture.*']" />
</ xe:options> </ xe:auto-completion-field>

Caution: This will load the entire result set of the initial asset query into the local memory of the client and it will stay there even after entering another search term into the text field. Therefore this option should only be used if sufficient selective query terms can be specified directly in the XPath expression so that the expected number of asset results remains low (approximately <500).

Example 3

Auto-completion field to select image assets. The ID of the selected asset is written in an asset feature of the type "asset reference". The generator runs an asset query on the censhare server using an XPath query. In contrast to the second example - here the filtering by the input value is not carried out by the client locally, but rather passed as part of the XPath query to the server. This option should always be used when the expected result set (assets) might be large (approximately > 500) or is unknown.

CODE
< xe:auto-completion-field source = "asset_feature[feature= 'mf:asset-ref2',value_long2= '0']@value_asset_id" search-value-source = "$temp@search" width = "200" popup-row-height = "50" popup-row-width = "250" max-items = "100" > <xe:options label-key="@name" value-key="@id" lookup-expression="=:cs:get-asset(asset/asset_feature[@feature='mf:asset-ref2']/@value_asset_id, 0, 0)>
< xe:generator expression = " =:if ($temp/temp/@search and string-length($temp/temp/@search) > 2) then cs:asset()[@censhare:asset.type= 'picture.*' and @censhare:asset.name like concat('*', $temp/temp/@search, '*')] else ()" />
</ xe:options>
</ xe:auto-completion-field>

Example 4

Auto-completion field to select image assets. The text in the suggestion list is formatted via an XSLT and an associated CSS.

             

CODE
< xe:auto-completion-field source = "asset_feature[feature= 'mf:asset-ref2',value_long2= '0']@value_asset_id" css-key = "asset-info" expression-id = "asset-ref-list" width = "200" max-items = "1000" > < xe:options label-key = "@name" value-key = "@id" >
< xe:generator expression = " =:cs:asset()[@censhare:asset.type= 'picture.*']" />
</ xe:options>
</ xe:auto-completion-field>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.