Formatting and parsing functionality for values.
Methods
(static) formatAttribute(obj, attr, propsopt) → {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 |
<optional> |
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, propsopt) → {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 “autonumber”, “integer”, “long”, "decimal", “datetime”, “boolean”, “binary”, “string”, “hashstring”, “enum”. |
|||||||||||||||||||||
props |
Object |
<optional> |
Properties
|
Returns:
formatted value
- Type
- string
Examples
mx.parser.formatValue(Big(3000), "decimal", { places: 2 }); // "3000.00"
mx.parser.formatValue(+new Date(1980, 7, 23), "datetime",
{ datePattern: "dd-MM-yyyy" }); // "23-08-1980"
(static) parseValue(value, type, propsopt) → {external:Big|string|Date|boolean}
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 “autonumber”, “integer”, “long”, "decimal", “datetime”, “boolean”, “binary”, “string”, “hashstring”, “enum”. |
|||||||||||||||||||||
props |
Object |
<optional> |
Properties
|
Returns:
the value if the value could be parsed, otherwise null
. The return type depends on the type of
the attribute as follows:
Attribute type | Return type |
---|---|
Integer, Long, Decimal | external:Big |
Autonumber | string |
DateTime | Date |
Enum | string |
String | string |
Boolean | boolean |
- Type
- external:Big | string | Date | boolean
Examples
mx.parser.parseValue("3,000.00", "decimal"); // Big(3000)
mx.parser.parseValue("23-8-1980", "datetime",
{ datePattern: "dd-M-yyyy" }); // Date(1980, 7, 23)