Fetching Data

After you have learned about making connections in your app, you would want to fetch data from different locations to your app. Let’s now see how this can be done;

  • In Miracle Studio’s Designer, click on an object you wish to fetch data into
  • On the right-hand side properties portion, click on the Bindings tab
  • Click on the + Add button
  • You would be seeing a box with fields, let’s understand different parts of it

Bindings

All Controls can have an input data source, which usually uses the Entities from the Connectors to populate data or configure attributes in controls like List Views, Text Boxes, Labels, etc. It is also possible to use a string format expression to produce output results in a particular format, like date and mathematical values. For example, ‘{dd MMM yyyy}’ will provide date as ’10 MAR 2020′.

Some of the properties which are used in Data-Binding include:

  • Value
    The default attribute of all controls which maps to the most common property. For example, for Text Boxes, it sets the text.
  • IsVisible
    This is another common attribute in all controls used to show or hide a control based on some criteria. For example, certain text boxes should only appear when a particular value is selected in a picker control preceding it.
  • DataSource
    Controls like Pickers, Segmented Controls, Auto-Complete Text Boxes and List Views require a data source to populate their list values. These data sources can be configured through control-binding.
  • IsEnabled
    Another common attribute in all controls used to allow or prevent editing in a control. For example, certain text boxes should only appear pre-filled in a read only format, editable only to certain groups of users.
  • SelectedValue
    For controls like Lists, Pickers, etc., the default selected item can be bound. Selected items may also be updated through binding if there are two fields that are related to each other.
  • Text
    For Text Box controls, the ‘Value’ attribute is same as the ‘Text’ property, however, it is an attribute used to bind certain values to the ‘Text’ properties of other controls like Labels, Buttons, etc.
  • TextColor
    Depending on certain criteria (like urgency or due date), it might become necessary to update the text color of certain buttons or labels. This can be done by binding expressions to the ‘TextColor’ property.
  • BackgroundColor
    The Background Color can be made dynamic for certain controls like Text boxes, Labels, Buttons, Layouts, etc. by using binding expressions with the ‘BackgroundColor’ property.
  • Literal
    When an exact match of value is required
  • Property
    When it is used as a property
  • Expression
    When some logical decision-making is undertaken via an expression

Example:

Let’s further understand the concept of fetching data via an example:

For this example we shall be using an MsSQL Connector.

Before you fetch any data, let’s make sure that the link i.e. connection used is properly set up. To check that; open the Connections sub-menu, click on the Entities tab and make sure the entities you wish to use with your connection are dragged in the top portion.

Data Submission Entities

If your database is properly set up, everything would flow smoothly.

Check or uncheck your required options and select the Get Service and Submit Service.

Now, head over to the page in designer view.

In this example, the user gets age fetched on to a textbox.

fetching-data-3

Now click on the textbox and in the right-hand side properties menu, click on the Bindings tab.

After that, set the Attribute, Binding Type and Value accordingly. Below is the illustration for our particular example:

Add Attribute, Binding Type and Value

Now Save everything and you have your textbox fetching data from a database perfectly.