wire.data.DataModel
Using a data model is a convenient way to share meta data about the structures in a data services across all queries.
Field Properties
Name | Description |
Alias | Used to register a friendly name for the field used in components and other UI containers |
Calc | Creates a new calculated column on the datatable returned by the data source. See Calculated Columns for details. |
Entity | Identifies the entity or table in the data service |
Name | Identifies the field name in the data service |
Format | The formatting specification for the field |
The example below sets up a data model on a data source. Alias names for labels and formatting are set up for fields in the data service. This meta data will automatically be applied to all fields in result sets for any query executed using the data source. As such they can automatically be leveraged by any components or other UI elements displaying the result sets.
Entity Wildcards
Wildcards (*
) can be used with a field's Entity
property to apply the field model data to any field in any entity containing the field Name
.
The example below will result in any field called Sales
in any entity to be formatted as currency and with two decimal places.
Calculated Columns
The example below creates a new calculated column called ProfitMargin
on the resulting datatable that is returned from any query that contains the entity Metrics
. The calculation uses the existing Sales
and Cost
columns on the table to return the value for the new calculated column.
For more examples, visit DataSource DataModels.
Last updated