Template Canvas

General

images/download/attachments/1704686/templateConvas0.PNG

Component Palette Icon:

images/download/attachments/1704686/TemplateCanvas1.PNG


Description

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. Follow this link to find out more information about MigLayout.

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 works 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

Name

Description

Property Type

Scripting

Category

Background Color

The background color of the component.

Color

.background

Appearance

Border

The border surrounding this component. NOTE that the border is unaffected by rotation.

Border

.border

Common

Data Quality

The data quality code for any tag bindings on this component.

int

.dataQuality

Data

Layout Constraints

The overal layout constraints for the canvas

String

.layoutConstraints

Behavior

Name

The name of this component.

String

.name

Common

Scroll Behavior

Controls wich direction(s) the canvas will scroll in

int

.scrollBehavior

Behavior

Templates

A dataset containing a row per template to instantiate.

Dataset

.templates

Data

Visible

If disabled, the component will be hidden.

boolean

.visible

Common

Scripting
Scripting Functions

.getAllTemplates()

  • Description

Returns a list of the templates that comprise the template canvas.

  • Parameters

Nothing

  • Return

List

  • Scope

Client

.getTemplate(name)

  • Description

Obtains the designated template object from the template canvas.

  • Parameters

name - The name of the template as defined by the "name" column of the dataset populating the template canvas.

  • Return

PyComponentWrapper

  • Scope

Client

Extension Functions

initializeTemplate

  • Description

This will be called once per template that is loaded. This is a good chance to do any custom initialization or setting parameters on the template.

  • Parameters

Self- A reference to the component that is invoking this function.

template - The template. The name of the template in the dataset will be available as template.instanceName

  • Return

Nothing

  • Scope

Client

Event Handlers

propertyChange

propertyChange

Fires whenever a bindable property of the source component changes. This works for standard and custom (dynamic) properties.

Property

Description

source

The component that fired this event

newValue

The new value that this property changed to.

oldValue

The value that this property was before it changed. Note that not all components include an accurate oldValue in their events.

propertyName

The name of the property that changed. NOTE: remember to always filter out these events for the property that you are looking for! Components often have many properties that change.

Customizers

This component has a customizer.

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
templates = event.source.parent.getComponent('Template Canvas').getAllTemplates() #Get all the template instances of the canvas.
for template in templates: #The templates are a list therefore you can iterate through them.
print template.ContentValue #You can access the properties of the template. This example prints the ContentValue custom property to the console.