Setting field data types

Flexmonster supports multiple field data types depending on your data source. The field's data type determines how the field is presented in the component, how its members are sorted, and which aggregation functions and filters can be applied to the field.

Supported data types

The following data types are supported in Flexmonster:

  • String

  • Integer

  • Float (Double)

  • Number

  • Boolean

  • Date

  • Date and time

  • Time

How to set a field's data type

You can set a field's data type using the schema (for the server), the mapping (for client-side parsers), or the embedded JSON or CSV metadata.

If the type is not specified or is invalid (e.g., type: "something"), the type is resolved automatically.

Using the schema (only for the Flexmonster server)

Step 1. In Flexmonster Admin Panel, go to the Data sources tab.

Step 2. Select the data source to enable the schema for.

Step 3. In the Data source details view, enable the Schema toggle.

Step 4. Choose field types from the drop-down menu: String, Integer, Double, Number, Boolean, Date, Date & Time, or Time.

Choosing field data types in the schema configuration

Step 5. Select Save changes to apply the schema configuration.

Using the mapping (only for client-side parsers)

Specify a data type for a field using the mapping.<field_name>.type property:

dataSource: {  
  type: "json",  
  data: [  
    ["Price", "Item", "Order Date"],  
    [100, "Headphones", "2025-04-12"]  
  ],   
  mapping: {  
    "Order Date": {
      type: "date"
    }  
  }  
}

Using JSON or CSV metadata

Set a field's data type directly in your JSON or CSV data source by using the type metadata property (for JSON) or the #dataType metadata annotation (for CSV).

Types in the metadata are overridden by the types set in the schema or in the mapping. If the type in the schema or mapping is not specified or is invalid (e.g., type: "something"), then the type in the metadata is used. If the type in the metadata is also invalid or the metadata is not specified, the type is resolved automatically.

Automatic type resolution

If you omit the field’s data type, the component will automatically resolve it based on the field’s first 50 values.

The automatic type resolution may produce unexpected results when:

  • The field values are null, undefined, or NaN.

  • The field values are not formatted correctly. For example, numbers have different decimal separators or are specified in hexadecimal form instead of decimal.

  • The field values are specified in different formats. For example, the first 50 values of a field consist of 25 numbers and 25 strings.

See also