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-11/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:
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
+
218
219
The following example formats a date attribute using a custom month-year pattern:
219
220
220
221
```ts
@@ -227,13 +228,82 @@ if (myDateAttribute.formatter.type === "datetime") {
227
228
}
228
229
```
229
230
230
-
For enumeration and Boolean attributes, `format` converts the raw value into a human-readable caption as configured in Studio Pro:
231
+
`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"
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`:
231
275
232
276
```ts
233
277
// myEnumAttribute is an EditableValue<string>
234
278
const caption =myEnumAttribute.formatter.format(myEnumAttribute.value); // e.g. "In Progress"
235
279
```
236
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:
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-9/pluggable-widgets/pluggable-widgets-client-apis-9/_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:
185
+
186
+
*`{ type: "date" }` — platform default date format
187
+
*`{ type: "time" }` — platform default time format
188
+
*`{ type: "datetime" }` — platform default datetime format
189
+
*`{ type: "custom", pattern: "..." }` — custom Unicode date pattern (for example `"EEEE"`, `"dd MMMM"`, `"MMMM YYYY"`)
190
+
190
191
The following example formats a date attribute using a custom month-year pattern:
191
192
192
193
```ts
@@ -199,13 +200,82 @@ if (myDateAttribute.formatter.type === "datetime") {
199
200
}
200
201
```
201
202
202
-
For enumeration and Boolean attributes, `format` converts the raw value into a human-readable caption as configured in Studio Pro:
203
+
`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"
241
+
}
242
+
```
243
+
244
+
##### Plain SimpleFormatter
245
+
246
+
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`:
203
247
204
248
```ts
205
249
// myEnumAttribute is an EditableValue<string>
206
250
const caption =myEnumAttribute.formatter.format(myEnumAttribute.value); // e.g. "In Progress"
207
251
```
208
252
253
+
##### Custom Formatters via setFormatter
254
+
255
+
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-9/#association), and is defined as follows:
0 commit comments