Formatting and parsing functionality for values.
Methods
(static) formatAttribute(obj, attr, propsnullable) → {string}
Converts an MxObject
attribute to a string in the
requested format.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
mendix/lib/MxObject |
|
|
attr |
string | attribute to fetch |
|
props |
Object | Object |
<nullable> |
passed to
|
Returns:
formatted value
- Type
- string
Example
mxobj.set("createdDate", +new Date(1980, 7, 23));
mx.parser.formatAttribute(mxobj, "createdDate",
{ datePattern: "dd-MM-yyyy" }); // 23-08-1980
(static) formatValue(value, type, propsnullable) → {string}
Converts a value to a string in the requested format.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
* | value to convert |
|
type |
string | Data type as which to interpret value. Can be one of “float”, “currency”, “autonumber”, “integer”, “long”, "decimal", “datetime”, “boolean”, “binary”, “string”, “hashstring”, “enum”. |
|
props |
Object | Object |
<nullable> |
For date conversions: parameters passed to |
Returns:
formatted value
- Type
- string
Examples
mx.parser.formatValue(Big(3000), "currency"); // "3000.00"
mx.parser.formatValue(+new Date(1980, 7, 23), "datetime",
{ datePattern: "dd-MM-yyyy" }); // "23-08-1980"
(static) parseValue(value, type, propsnullable) → {number|string|Date}
Converts a string in the given format to a value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | string to convert |
|
type |
string | Data type as which to interpret value. Can be one of “float”, “currency”, “autonumber”, “integer”, “long”, "decimal", “datetime”, “boolean”, “binary”, “string”, “hashstring”, “enum”. |
|
props |
Object | Object |
<nullable> |
For date conversion: parameters passed to |
Returns:
the value if the value could be parsed, otherwise NaN
for numerical types and
null
for the datetime type
- Type
- number | string | Date
Examples
mx.parser.parseValue("3,000.00", "currency"); // 3000
mx.parser.parseValue("23-8-1980", "datetime",
{ datePattern: "dd-M-yyyy" }); // Date(1980, 7, 23)