Skip to main content
Version: 8.1

Vision - Template Canvas

Component Palette Icon:

The template canvas is similar to the template repeater but allows for more control of the templates than the template repeater.

The "Templates" property on the template canvas is a dataset. Each row in this dataset represents a manifestation of a template. It can be the same template or a different template on each row. This dataset allows for control over the size, position and layout of the template. There are two methods of controlling the layout of each template inside the template canvas:

  • Absolute Positioning: The location of the template is explicitly managed through the "X" and "Y" columns of the "Templates" property's dataset. Consequently the columns labeled "width" and "height" control the size of the template.
  • Layout Positioning: The template canvas uses "MiGLayout" to manage the location of the template. MigLayout is a common albeit complicated layout methodology. It supports layouts that wrap the templates automatically as well as docking the template to one side of the template canvas. You can learn more about MiG Layout at http://www.miglayout.com.

In addition, control over data inside each template can be achieved by adding a column with the name "parameters" to the dataset and populating this column with dictionary style key words and definitions.

Additional templates can be added to the template canvas by inserting an additional row to the "Templates" property's dataset. The same applies to removing the templates but with removing the rows from the dataset.

Properties​

NameDescriptionProperty TypeScriptingCategory
Background ColorThe background color of the component. Can be chosen from color wheel, chosen from color palette, or entered as RGB or HSL value. See Color Selector.Color.backgroundAppearance
BorderThe border surrounding this component. Options are No border, Etched (Lowered), Etched (Raised), Bevel (Lowered), Bevel (Raised), Bevel (Double), and Field Border.
Note: The border is unaffected by rotation.

Changed in 8.1.21
As of 8.1.21, the "Button Border" and "Other Border" options are removed.
Border.borderCommon
Layout ConstraintsThe overall layout constraints for the canvas.String.layoutConstraintsBehavior
NameThe name of this component.String.nameCommon
QualityThe data quality code for any Tag bindings on this component.QualityCode.qualityData
Scroll BehaviorControls which direction(s) the canvas will scroll in.int.scrollBehaviorBehavior
Show LoadingIf false, the loading indicator will never be shown.boolean.showLoadingAppearance
TemplatesA dataset containing a row per template to instantiate.Dataset.templatesData
VisibleIf disabled, the component will be hidden.boolean.visibleCommon

Scripting​

See the Vision - Template Canvas Scripting Functions page for the full list of scripting functions available for this component.

Event Handlers​

Event handlers allow you to run a script based off specific triggers. See the full list of available event handlers on the Component Events page

Customizers​

This component has its own customizer called the Template Canvas Customizer. The Template Canvas Customizer allows you to create multiple instances of a template. Here is where you can configure some of the properties of the template instance that are inside the Template Canvas. To edit a template instance, select it from the Instances list. To cancel your edit and add a new instance instead, click the Cancel button in the bottom left.

Templates Property

The "Templates" property, in the Property Editor, stores all the data that is entered into the customizer. New template instances can be created directly on the "Templates" property as well. To edit or view the dataset, click the Dataset Viewer next to the "Templates" property.

Template Canvas Customizer - Property Descriptions​

PropertyDescription
InstancesA list of the templates currently in the Template Canvas.
Add/Edit InstancesSection of the Template Canvas Customizer where you add new instances and edit existing instances. Select an instance from above to edit that instance.
NameName of the selected template instance.
Z-IndexThe index position along the Z axis that should be used for the instance. If left empty, then Z order will be determined by the row index position of the instance as it sits in the Template Canvas' Templates property.
TemplateThe template path for the selected template instance.
Absolute PositioningSets the position and size of the components inside the template. In order from left to right, the four boxes are X, Y, Width, and Height.
Layout PositioningUses MiGLayout to manage template location. It allows you to easily determine the layout of components or templates within a container (i.e., "span,wrap"). To learn more, go to http://www.miglayout.com
ParametersShows a list of all the parameters that are defined in the selected template. Specify the values for each template parameter. To make this dynamic, you must bind the Templates property of the Template Canvas.

More information on the Template Canvas Customizer can be found on the Component Customizers page.

Data Types and the Parameters Field​

The "Parameters" field in the customizer accepts string values, but attempts to convert the value if the underlying template parameter is set to a non-string type. In some cases this may require special formatting on the supplied string. The table below provides some examples.

Data TypeExpected FormatFormat Examples
ColorColors may be entered in as either a name, or an RBG stringred
0,0,255
DateDate objects may be entered as either a UNIX timestamp in milliseconds, or in the following notation. In all cases, quotation marks should not be added.
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd
MM/dd/yyyy
MM/dd/yyyy HH:mm:ss
hh:mm:ss a
hh:mm a
MM/dd/yyyy hh:mm:ss a
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss
EEE MMM dd HH:mm:ss z yyyy
1591374627000
2020-03-28 06:38:00:000

Examples​

Code Snippet
#This example demonstrates how to pull value information from templates that are inside the template canvas.
#This example assumes that each template has a custom property called ContentValue

#Get all the template instances of the canvas.
templates = event.source.parent.getComponent('Template Canvas').getAllTemplates()

#The templates are a list therefore you can iterate through them.
for template in templates:

#You can access the properties of the template. This example prints the ContentValue custom property to the console.
print template.ContentValue
Code Snippet - Seach by Name

#This example demonstrates how to iterate through each template in a template canvas
#looking for a named instance. Once found, print the value of a property on a component in
#that instance.

#This assumes that the canvas contains a template instance named "timerTemplate" and
#a Timer component (named Timer) is inside the instance.

#Create a reference to the Template Canvas
canvas = event.source.parent.getComponent('Template Canvas')

#Retrieve all template instances in the canvas
tempInstance = canvas.getAllTemplates()

#Iterate through each template instance
for template in tempInstance:

#Compare the name of each instance.
if template.getInstanceName() == "timerTemplate":

#Print the Value property on the Timer component inside the template
print template.getComponent("Timer").value
Code Snippet - Read User Input Example
#This script will retrieve a list of all templates in a template canvas, and record user input.

#The code was originally design to work with the Read User Input example above,
#but can be easily modified to work with different templates.

#Reference the template canvas component, and call the getAllTemplates() method.
#This will return a list of every instance in the canvas
templateList = event.source.parent.getComponent('Template Canvas').getAllTemplates()

#Initialize a list. User input from each text field will be stored in this variable
userInput = []

#Iterate through each template instance inside the canvas
for template in templateList:

#add the user inputted value to the userInput list. The values are originally returned in Unicode.
#the Python str() function is casting the Unicode values as string values.
userInput.append(str(template.TextField_Text))

#Show the values in a messageBox. This could be replaced with an INSERT query, or some other action.
#str() is used again to case the list as a string. This only required to work with the messageBox function
#since the function requires a string argument be passed in
system.gui.messageBox(str(userInput))