Check List¶
The CheckList widget in Emakin allows multiple selections from a list of checkboxes. List options can be sourced from various data sources, including static lists or query results.
XML Fields¶
Stored Values¶
XPathselects the collection or value that receives the selection.ItemXPathselects individual stored items.ValueXPathselects the source field written for each selected item;CaptionXPathselects the display text stored with it. In Single Mode, the selected values are represented in one data element as described below.
Choice Source and Presentation¶
DataSourcessupplies the selectable items.MonitoredXPathslists values that reload those items when changed.LayoutselectsVerticalorHorizontalcheckbox arrangement.RequiredForGrouprequires a selection when the matching validation group is evaluated.Hintsgives user help andRulescontrols conditional behavior.
Single Mode¶
CheckList supports two different storage models. The default model stores each selection as a separate XML item. Single Mode stores all selected values in the text value of the node selected by XPath.
Enable Single Mode by setting ItemXPath to !. Here, ! is a mode marker, not an XPath expression. Consequently, ValueXPath, CaptionXPath, data-source mappings, and the State attribute are not used to write the data model.
| Default mode | Single Mode | |
|---|---|---|
XPath target | A container for the selected-item sequence | One scalar XML element or attribute |
ItemXPath | XPath for each item in the sequence, for example Item or * | ! |
| Stored value | One XML item per checked option | A comma-separated string such as 1,3 |
| Caption and mappings | May be stored on each XML item | Not stored or executed by CheckList |
| Selection lifecycle | New, existing, and unchecked items can carry State | The complete string is replaced; no per-item state exists |
| Suitable when | Each selection needs metadata, mappings, or change tracking | Only the selected identifiers need to be saved compactly |
Data Model Comparison¶
For the examples below, assume that the user checks Item 1 (1) and Item 3 (3). Data is only the enclosing form data root; the actual root element can have a different name.
Default mode: sequence of selected items¶
The regular example uses XPath="List" and ItemXPath="*". In a schema, * resolves to the allowed child element of the List sequence. If that child element is named Item, the resulting data is structurally equivalent to:
1 2 3 4 5 6 7 8 9 10 11 12 | |
ValueXPath and CaptionXPath are evaluated relative to every selected Item. They may point to child elements, as above, or to attributes. For example, ValueXPath="@Value" and CaptionXPath="@Caption" would produce <Item Value="1" Caption="Item 1" State="Temp" />.
On a later edit, an item that is unchecked is retained in the data model with State="Deleted"; a previously stored item that remains checked has no State attribute. This preserves the per-item lifecycle until $Xml.CommitDeletes() clears it. The widget also executes data-source mappings for newly created items, so this mode can persist additional fields beyond value and caption.
Single Mode: one scalar value¶
The Single Mode example uses XPath="SingleMode" and ItemXPath="!". With the same two checked options, it creates or updates only this one value:
1 2 3 | |
There are no child Item nodes, captions, mappings, or State attributes. When the selection changes, CheckList rewrites the complete text value; for example, changing the selection to Item 2 produces <SingleMode>2</SingleMode>. An empty selection produces an empty value.
Single Mode Value Rules¶
- Values must be unique, non-empty identifiers. A duplicate value would address the same checkbox row.
- Do not use commas in data-source values: commas are the storage delimiter. On load, surrounding whitespace is ignored.
- Single Mode is appropriate when labels can always be obtained from the current data source. Use the default mode if historical captions, additional mapped fields, or an item-level deletion audit are required.
Remarks¶
Default Behavior¶
- The CheckList widget uses a sequence-type data model to store selected items.
- Checked Items: Each selected item creates a new element in the data model with the corresponding value.
Data Mapping¶
-
Value Assignment:
- Defined by the data source item's
Valueproperty using theValueXPathproperty. - Default: Empty string, assigning the data source item value to the new element.
- Defined by the data source item's
-
Label Assignment:
- Defined by the data source item's
Textproperty using theCaptionXPathproperty. - Default: Empty string, assigning the data source item's
Textproperty to the new element'sCaptionattribute.
- Defined by the data source item's
State Attribute¶
The CheckList widget supports monitoring list item changes using the State attribute:
Temp: Marks newly checked items.- Existing Items: Preserved as is.
Deleted: Marks items that were unchecked.
Clearing the State Attribute:
Use the scripting method $Xml.CommitDeletes() to reset the State attribute.
Example¶
An example checklist widget that uses data sources can be defined as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Related Pages¶
Single Mode Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |