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
The Mendix platform provides two typed, configurable built-in formatters that extend `SimpleFormatter<T>`. 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
+
220
221
The following example formats a date attribute using a custom month-year pattern:
221
222
222
223
```ts
@@ -229,13 +230,82 @@ if (myDateAttribute.formatter.type === "datetime") {
229
230
}
230
231
```
231
232
232
-
For enumeration and Boolean attributes, `format` converts the raw value into a human-readable caption as configured in Studio Pro:
233
+
`getFormatPlaceholder` returns a locale-appropriate placeholder string for the active date pattern, useful for input field `placeholder` attributes:
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`:
233
277
234
278
```ts
235
279
// myEnumAttribute is an EditableValue<string>
236
280
const caption =myEnumAttribute.formatter.format(myEnumAttribute.value); // e.g. "In Progress"
237
281
```
238
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:
0 commit comments