Skip to content

Commit ac872bc

Browse files
authored
Merge pull request #11159 from mlaponder/wtf/single-object-ds-docs
[WTF-2648] Extend pluggable widget API docs for single object datasource
2 parents 7fca586 + 2db3921 commit ac872bc

4 files changed

Lines changed: 65 additions & 26 deletions

File tree

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/pluggable-widgets/pluggable-widgets-property-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ When the property is defined as follows:
775775

776776
Then the Studio Pro UI for the property appears like this:
777777

778-
{{< figure src="/attachments/apidocs-mxsdk/apidocs/pluggable-widgets/pluggable-widgets-property-types/datasource.png" class="no-border" >}}
778+
{{< figure src="/attachments/apidocs-mxsdk/apidocs/pluggable-widgets/pluggable-widgets-property-types/datasource-list.png" class="no-border" >}}
779779

780780
### Selection {#selection}
781781

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/pluggable-widgets/pluggable-widgets-property-types.md

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ This defines a property's type. A `type` must be one of the following:
5959
* [object](#object)
6060
* [file](#file)
6161
* [datasource](#datasource)
62+
* [List data source](#list-datasource)
63+
* [Object data source](#object-datasource)
6264
* [selection](#selection)
6365

6466
### XML Elements
@@ -480,9 +482,6 @@ Then the Studio Pro UI for the property appears like this:
480482

481483
### Action {#action}
482484

483-
{{% alert color="info" %}}
484-
The `defaultType` and `defaultValue` attributes for Action were introduced in Mendix [10.15](/releasenotes/studio-pro/10.15/).
485-
{{% /alert %}}
486485

487486
The action property type allows a user to configure an action which can do things like call nanoflows, save changes, and open pages.
488487

@@ -746,41 +745,37 @@ Then the Studio Pro UI for the property appears like this:
746745

747746
### Datasource {#datasource}
748747

749-
The datasource property allows widgets to work with object lists. The client component will receive value prop of type [`ListValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listvalue) and may be used with [`action`](#action), [`attribute`](#attribute), [`association`](#association), [`expression`](#expression), [`text template`](#texttemplate), and [`widgets`](#widgets) properties. See [Data Sources](/refguide/data-sources/#list-widgets) for available data source types.
748+
The datasource property allows widgets to work with data from the Mendix Platform. It comes in two variants controlled by the `isList` attribute: a **list data source** (`isList="true"`) for working with collections of objects, and an **object data source** (`isList="false"`) for working with a single object.
750749

751750
If no data source has been configured by the user, any properties that are linked to the datasource property are automatically omitted from the props passed to the client component (even if they are marked as required).
752751

753-
{{% alert color="warning" %}}
754-
Only list datasources are supported, therefore specifying `isList="true"` is required.
755-
{{% /alert %}}
756-
757752
#### XML Attributes
758753

759754
| Attribute | Required | Attribute Type | Description |
760755
|----------------|----------|----------------|------------------------------------------------------------------------------------------------------------|
761756
| `type` | Yes | String | Must be `datasource` |
762757
| `key` | Yes | String | See [key](#key) |
763-
| `isList` | Yes | Boolean | Must be `true` |
758+
| `isList` | Yes | Boolean | `true` for a list data source, `false` for an object data source |
764759
| `required` | No | Boolean | This decides if the user is required to specify a datasource, `true` by default |
765-
| `defaultType` | No | String | Default type for the property, supported values are `Database`, `Microflow`, `Nanoflow`, and `Association` |
760+
| `defaultType` | No | String | Default type for the property, see [Default Data Sources](#data-source-defaults) |
766761
| `defaultValue` | No | String | Default value for the property, see [Default Data Sources](#data-source-defaults) |
767762

768763
##### Data Source Defaults {#data-source-defaults}
769764

770-
{{% alert color="info" %}}
771-
The `defaultType` and `defaultValue` attributes for datasources were introduced in Mendix [10.16](/releasenotes/studio-pro/10.16/).
772-
{{% /alert %}}
773-
774765
You can use the `defaultType` and `defaultValue` attributes to configure default data sources for your widget. Unless overridden in Studio Pro, the widget will attempt to configure the data source according to its defaults. Both attributes need to be set for the defaults to be applied.
775766

776767
The format of `defaultValue` depends on the chosen `defaultType`:
777768

778-
| Data source type | Format | Example |
779-
|--------------------------|-------------|-----------------------------------------------------------------------|
780-
| `Database` `Association` | Entity Path | `ModuleName.EntityName` or `ModuleName.A/ModuleName.A_B/ModuleName.B` |
781-
| `Microflow` `Nanoflow` | Document ID | `ModuleName.DocumentName` |
769+
| Data source type | Format | Example | Supported For |
770+
|--------------------------|-------------|-----------------------------------------------------------------------|------------------------------------|
771+
| `Database` `Association` | Entity Path | `ModuleName.EntityName` or `ModuleName.A/ModuleName.A_B/ModuleName.B` | List data source |
772+
| `Microflow` `Nanoflow` | Document ID | `ModuleName.DocumentName` | List and object data source |
782773

783-
#### Studio Pro UI
774+
#### List Data Source {#list-datasource}
775+
776+
A list data source (`isList="true"`) allows a widget to work with a collection of objects. The client component receives a prop of type [`ListValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listvalue). For more information on available data source type, see [Data Sources](/refguide/data-sources/#list-widgets).
777+
778+
##### Studio Pro UI
784779

785780
When the property is defined as follows:
786781

@@ -793,14 +788,57 @@ When the property is defined as follows:
793788

794789
Then the Studio Pro UI for the property appears like this:
795790

796-
{{< figure src="/attachments/apidocs-mxsdk/apidocs/pluggable-widgets/pluggable-widgets-property-types/datasource.png" class="no-border" >}}
791+
{{< figure src="/attachments/apidocs-mxsdk/apidocs/pluggable-widgets/pluggable-widgets-property-types/datasource-list.png" class="no-border" >}}
797792

798-
### Selection {#selection}
793+
#### Object Data Source {#object-datasource}
799794

800795
{{% alert color="info" %}}
801-
The property type was introduced in Mendix [10.7](/releasenotes/studio-pro/10.7/).
796+
The object data source was introduced in Mendix [11.11](/releasenotes/studio-pro/11.11/).
802797
{{% /alert %}}
803798

799+
An object data source (`isList="false"`) allows a widget to work with a single object. The client component receives a prop of type [`DynamicValue<ObjectItem>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis/#dynamic-value).
800+
801+
A widget may have, at maximum, **one** object data source property.
802+
803+
The available source types differ from list data sources:
804+
805+
| Platform | Available Source Types |
806+
|----------|-----------------------------------------------------------|
807+
| Web | Context, Microflow, Nanoflow, Listen to widget |
808+
| Native | Context, Microflow, Nanoflow |
809+
810+
##### Studio Pro UI
811+
812+
When the property is defined as follows:
813+
814+
```xml
815+
<property key="data" type="datasource" isList="false" required="false">
816+
<caption>Data source</caption>
817+
<description />
818+
</property>
819+
```
820+
821+
Then the Studio Pro UI for the property appears like this:
822+
823+
{{< figure src="/attachments/apidocs-mxsdk/apidocs/pluggable-widgets/pluggable-widgets-property-types/datasource-single-object.png" class="no-border" >}}
824+
825+
#### Linking Properties to Data Sources {#datasource-linking}
826+
827+
The [`action`](#action), [`attribute`](#attribute), [`association`](#association), [`expression`](#expression), [`text template`](#texttemplate), [`widgets`](#widgets), and [`selection`](#selection) properties can be linked to a data source using the `dataSource` attribute on those properties. The client type received by the component depends on the data source type:
828+
829+
| Property type | List data source client type | Object data source client type |
830+
|:---------------|:-----------------------------|:--------------------------------------|
831+
| `action` | [`ListActionValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listactionvalue) | [`ActionValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis/#action-value) |
832+
| `attribute` | [`ListAttributeValue<T>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listattributevalue) | [`EditableValue<T>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis/#editable-value) |
833+
| `association` | [`ListReferenceValue` or `ListReferenceSetValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listassociationvalue) | `ReferenceValue` or `ReferenceSetValue` |
834+
| `expression` | [`ListExpressionValue<T>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listexpressionvalue) | [`DynamicValue<T>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis/#dynamic-value) |
835+
| `textTemplate` | [`ListExpressionValue<string>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listexpressionvalue) | [`DynamicValue<string>`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis/#dynamic-value) |
836+
| `widgets` | [`ListWidgetValue`](/apidocs-mxsdk/apidocs/pluggable-widgets-client-apis-list-values/#listwidgetvalue) | `ReactNode` |
837+
| `selection` | `SelectionSingleValue` or `SelectionMultiValue` | *Not supported* |
838+
839+
### Selection {#selection}
840+
841+
804842
The selection property allows a widget to read and set a selection that can be used in actions, expressions, or a `Listen to` data source of a data view.
805843

806844
#### XML Attributes
@@ -813,6 +851,10 @@ The selection property allows a widget to read and set a selection that can be u
813851
| `defaultValue` | No | String (Expression) | Default value for the property |
814852
| `onChange` | No | Property Path | The path to an [`action`](#action) property that will be run by the Mendix Platform when the selection is changed by the widget |
815853

854+
{{% alert color="warning" %}}
855+
The `dataSource` attribute must refer to a [list data source](#list-datasource). Linking a selection property to an object data source is not supported.
856+
{{% /alert %}}
857+
816858
#### XML Elements
817859

818860
`<selectionTypes>` (required) — This element encapsulates `<selectionType>` elements which declare supported selection types available while configuring the selection property in Studio Pro.
@@ -867,9 +909,6 @@ Label property allows a pluggable widget to have labeling functionality similar
867909

868910
#### setLabel {#setLabel}
869911

870-
{{% alert color="info" %}}
871-
The `setLabel` attribute was introduced in Mendix [10.5](/releasenotes/studio-pro/10.5/).
872-
{{% /alert %}}
873912

874913
You can use `setLabel` to specify which properties can be used to set the `Label` property value.
875914

26.4 KB
Loading
36.6 KB
Loading

0 commit comments

Comments
 (0)