Merge JSON data into an HTML ViewBox Template

Description

Merging JSON data with the HTML ViewBox Template.

images/mjs13.png
JSON data displayed in a ViewBox Template

For more information on this topic, read the guide below or watch this video.

Define the JSON Data

  1. In the UX Builder on the UX Controls page open the 'Data Controls'. Select the [ViewBox] option to add a ViewBox control to the component.

    images/mjs.png
  2. In the properties list click on the button next to the ViewBox properties property, in the ViewBox Properties section.

    images/mjs2.png
  3. Open the Data Source Pane. Set the ViewBox type control to 'Data' in the 'ViewBox Datasource' section.

    images/mjs3.png
  4. In the ViewBox Data section set the Datasource type to be 'Static JSON'

    images/mjs4.png
  5. Click the button next to the 'Static JSON' property.

    images/mjs5.png
  6. In the 'Static JSON Data' dialog add the following JSON and click OK:

    {
    "name": "Fred",
    "city": "Boston"
    }
    images/mjs.png

Creating the Template

  1. Open the ViewBox Layout pane. Select the 'Genie' option and click the 'Add item' button.

    images/mjs7.png
  2. In the Category list select 'Data Controls' and in the 'Control' list select [Label]. On the right, highlight the two fields for 'name' and 'city' and click OK.

    images/mjs8.png
  3. Click OK to close the ViewBox Builder and run the component in Live Preview. You should see the JSON data displayed.

    images/mjs9.png

Modify the Template's HTML

  1. On the Design tab's UX Controls page highlight the ViewBox control. Click on the ViewBox properties property to open the ViewBox Builder again.

    images/mjs2.png
  2. Open the ViewBox Layout pane and select the 'Freeform editor' choice.

    images/mjs10.png
  3. The Freeform editor should contain the placeholders for the two fields you defined in JSON. This example used the Genie to add these placeholders to the template but it would have been just as easy to type them into the Freeform template by hand.

    images/mjs11.png
  4. Add some HTML around the placeholders Click OK to close the ViewBox.

    images/mjs12.png
  5. Run the component in Live Preview.

    images/mjs13.png