You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/pluggable-widgets/pluggable-widgets-client-apis/_index.md
+143Lines changed: 143 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,149 @@ There is a way to use more the convenient `displayValue` and `setTextValue` whi
163
163
164
164
The optional field `universe` is used to indicate the set of all possible values that can be passed to a `setValue` if a set is limited. Currently, `universe` is provided only when the edited value is of the Boolean or enumeration [types](/refguide/attributes/#type).
165
165
166
+
#### Formatter Details {#formatter-details}
167
+
168
+
The `formatter` field on `EditableValue` is defined as follows:
The Mendix platform provides two typed, configurable built-in formatters that extend `SimpleFormatter<T>`: `NumberFormatter` and `DateTimeFormatter`. The actual type of `EditableValue.formatter` is `ValueFormatter<T>` — a union that covers both built-in and plain formatters:
The `withConfig` method returns a **new formatter** with a different date pattern while preserving the user's locale. It accepts a `DateTimeFormatterConfig` with the following options:
215
+
216
+
*`{ type: "date" }`: platform default date format
217
+
*`{ type: "time" }`: platform default time format
218
+
*`{ type: "datetime" }`: platform default datetime format
219
+
*`{ type: "custom", pattern: "..." }`: custom Unicode date pattern (for example `"EEEE"`, `"dd MMMM"`, `"MMMM YYYY"`)
220
+
221
+
The following example formats a date attribute using a custom month-year pattern:
222
+
223
+
```ts
224
+
if (myDateAttribute.formatter.type==="datetime") {
const formatted =customFormatter.format(myNumberAttribute.value); // e.g. "1234.5600"
271
+
}
272
+
```
273
+
274
+
##### Plain SimpleFormatter
275
+
276
+
For **string**, **enumeration**, and **Boolean** attributes the platform provides a plain `SimpleFormatter<T>` without a `type` property. These formatters convert raw values to human-readable captions (for example, enum captions configured in Studio Pro) and parse text input back to the typed value. They do **not** have `withConfig` or `getFormatPlaceholder`:
277
+
278
+
```ts
279
+
// myEnumAttribute is an EditableValue<string>
280
+
const caption =myEnumAttribute.formatter.format(myEnumAttribute.value); // e.g. "In Progress"
281
+
```
282
+
283
+
##### Custom Formatters via setFormatter
284
+
285
+
You can supply a fully custom formatter for any attribute type using `setFormatter`. The object must implement `format` and `parse`:
`ModifiableValue` is used to represent values that can be changed by a pluggable widget client component. It is passed only to [association properties](/apidocs-mxsdk/apidocs/pluggable-widgets-property-types-10/#association), and is defined as follows:
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/pluggable-widgets/pluggable-widgets-client-apis/_index.md
+143Lines changed: 143 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,6 +161,149 @@ There is a way to use more the convenient `displayValue` and `setTextValue` whi
161
161
162
162
The optional field `universe` is used to indicate the set of all possible values that can be passed to a `setValue` if a set is limited. Currently, `universe` is provided only when the edited value is of the Boolean or enumeration [types](/refguide/attributes/#type).
163
163
164
+
#### Formatter Details {#formatter-details}
165
+
166
+
The `formatter` field on `EditableValue` is defined as follows:
The Mendix platform provides two typed, configurable built-in formatters that extend `SimpleFormatter<T>`: `NumberFormatter` and `DateTimeFormatter`. The actual type of `EditableValue.formatter` is `ValueFormatter<T>` — a union that covers both built-in and plain formatters:
The `withConfig` method returns a **new formatter** with a different date pattern while preserving the user's locale. It accepts a `DateTimeFormatterConfig` with the following options:
213
+
214
+
*`{ type: "date" }`: platform default date format
215
+
*`{ type: "time" }`: platform default time format
216
+
*`{ type: "datetime" }`: platform default datetime format
217
+
*`{ type: "custom", pattern: "..." }`: custom Unicode date pattern (for example `"EEEE"`, `"dd MMMM"`, `"MMMM YYYY"`)
218
+
219
+
The following example formats a date attribute using a custom month-year pattern:
220
+
221
+
```ts
222
+
if (myDateAttribute.formatter.type==="datetime") {
const formatted =customFormatter.format(myNumberAttribute.value); // e.g. "1234.5600"
269
+
}
270
+
```
271
+
272
+
##### Plain SimpleFormatter
273
+
274
+
For **string**, **enumeration**, and **Boolean** attributes the platform provides a plain `SimpleFormatter<T>` without a `type` property. These formatters convert raw values to human-readable captions (for example, enum captions configured in Studio Pro) and parse text input back to the typed value. They do **not** have `withConfig` or `getFormatPlaceholder`:
275
+
276
+
```ts
277
+
// myEnumAttribute is an EditableValue<string>
278
+
const caption =myEnumAttribute.formatter.format(myEnumAttribute.value); // e.g. "In Progress"
279
+
```
280
+
281
+
##### Custom Formatters via setFormatter
282
+
283
+
You can supply a fully custom formatter for any attribute type using `setFormatter`. The object must implement `format` and `parse`:
`EditableFileValue` is used to represent file values, that can be changed by a pluggable widget client component and is passed only to [file](/apidocs-mxsdk/apidocs/pluggable-widgets-property-types/#file). It is defined as follows:
0 commit comments