A5Helper_getJSONFormitems_fromDatabase Function

Syntax

C json = A5Helper_getJSONFormitems_fromDatabase(C connectionString, C tableName [, C fieldList])

Arguments

connectionStringCharacter

The AlphaDAO connection string to the SQL database (e.g., "::Name::Northwind").

tableNameCharacter

The name of the table to inspect.

fieldListCharacter

Optional. A comma-delimited list of fields to include in the generated form. If omitted, all fields in the table are included.

Returns

jsonCharacter

A JSON string containing the array of item definitions (the "items" array) required for the JSON Form control.

Description

Generates a JSON Form definition string by inspecting the schema of a table in a database.

Discussion

This helper function is designed to accelerate development by creating a starting point for your JSON Form based on an existing database schema. It maps SQL data types to the appropriate JSON Form control types (e.g., SQL 'Bit' fields become 'Switch' controls, 'Varchar' becomes 'Text' controls).

Example

dim cn as c = "::Name::Northwind"
dim table as c = "Customers"
dim json as c 

' Generate the items definition for the Customers table
json = A5Helper_getJSONFormitems_fromDatabase(cn, table)

' You can now use this JSON to set the properties of a JSON Form control

The A5Helper_getJSONFormITEMS_fromDatabase() function allows you to set any property in the dynamic form by adding settings to a new field in your database called Other.

You can define any control type to appear in your JSON form by specifying the properties for the control in the Other field in the table that is queried by the function.

Here is how to get the properties for an arbitrary control:

  • Create a UX component and add a JSON form to the UX.
  • Edit the JSON Form and define a control.
  • Click the Show... button (bottom left on JSON Form builder dialog) and select the Control Properties option. Check the checkbox control to show the syntax for the A5Helper_getJSONFormITEMS_fromDatabase() function.
  • Paste these property values into the Other field in SQL table.
Dialog showing control properties formatted for the A5Helper function.
Getting Control Properties

Videos

Defining Arbitrary Controls and Properties

Learn how to use the A5Helper_getJSONFormITEMS_fromDatabase function to define arbitrary controls and properties.

See Also