4D for Mobile Tutorial – Using Formatters

A data formatter allows you to map a data type from your database to a specific display on the mobile side. For example, you can define a date, percentage, or currency format. Data formatters can also call some code to create intelligent interfaces.

For example, you can attach a data formatter to phone numbers that open an action menu on the mobile app when the user touches the number (e.g., to call the person or save them in contacts).

You have three formatter types:

Built-in formatters

This tutorial will show you how to apply built-in formatters to your fields. We will:

  • define a format for a Boolean and a date,
  • specify that a number is a percentage and another a currency.

 

Static formatters

The statics formatters allow formatting of the data. The transformation is described in a JSON file. You can download statics formatters from the gallery or create your own. For example, the formatter “BoolToImage” in the gallery displays a red circle when the value is false and a green circle for the true value.

This tutorial shows you how to create your formatters:

  • text to text,
  • integer to text,
  • integer to the image.

 

Dynamic formatters

The dynamic formatters contain Swift and Kotlin code for iOS and Android. As for the static formatters, you can download them from the gallery or create your own formatters. In the documentation, you have a tutorial with a step-by-step example to create a formatter for Swift and one for Kotlin.

This video will show you how to get a formatter from the gallery and integrate it into your project. 

Next…

Voilà! Now you know how to format your data in your mobile application. To go further, you can continue with the blog or the documentation.

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.