This lesson is part of the Vision Templates course. You can browse the rest of the lessons below.


Autoplay Off


The Template Repeater repeats instances of templates any number of times. It can arrange them vertically, horizontally, or in a "flow" layout, which can either be top-to-bottom or left-to-right. If there are too many to fit, a scrollbar will be shown.

Video recorded using: Ignition 7.7


(open in window)

[00:00] Let's take a look at one of the most powerful components we have in Ignition called the template repeater. It can be found under the Containers tab of the Component Palette. The Template Repeater repeats instances of a template any number of times. It can arrange them vertically, horizontally, or in a flow layout which can either be top to bottom or left to right. If there are too many to fit, a scroll bar will be shown. This makes it easy to quickly create screens that represent many similar pieces of equipment. It can also be used to create screens that are dynamic, automatically configure themselves based on configurations stored in a database or tag structure. It's an easy component to use. The first thing we do is set the Template Path property here to the template what we want to repeat. So I can go and select here my Index Label. Then we specify the Repeat Behavior which is either Count or Dataset. If we specify Count, we're going to repeat it the number of times here based on the Repeat Count property. So if I set this property to 50, I'm going to repeat it 50 times. So here you can see I have this template now repeated 50 times. If I have more than I can see on the screen, I get a scroll bar. So if I go into Preview mode, I can actually go to the scroll bar to see all the templates here. Right now it's repeating this in a vertical layout style. Down here at the bottom is the property for it. If I can set this to horizontal, I can also set this to a flow which is pretty good in my case here. So the way that this particular behavior works, the Count, is that it expects the template here to have a property called Index which is the Index Parameter Name of this Template Repeater. And then the first one we're going to set to zero, then one, all the way up to the Repeat Count minus one, so zero to 49 here. So my Index Label, this template, has a parameter here called Index which is the exact same name as integer. I'm just showing that Index on the LED display so you can see it. As you can see, it's repeating it 50 times, zero to 49. The second type of repeat behavior is the Dataset, where I can actually repeat it based off of a dataset, where the number of rows we have in a dataset is the number of templates I'm going to show on the screen. This time I'm going to set my template path to a tank, and I'll set it to repeat behavior Dataset and then there's a property here called Template Parameters which is the dataset that we're going to use here. Every row in that dataset is going to repeat that template. So I'm going to go in here to the Dataset Viewer and I'm going to add a dataset manually. We have to make sure we create a column for every single parameter that we want to set on this template, now my template only has one parameter called tankNum, it's Integer, so I got to make sure I add this column here to my dataset. I'm going to call it tankNum, it's an Integer here, go ahead and press OK, now I got that column, I'm going to add five rows here. I'm going to go 100, 101, 102, 203, and 104. Those are the tank numbers. Soon as I press OK, I've added five rows, I'll see that get repeated here five times. And right now, of course, the layout style is Flow, so I'm getting it to flow on the screen. So I can make this as big or as small as I want on the screen, and if it goes off, I would get a scroll bar here. So the way this works is, I have this template here called Tank Tank, it has a tankNum property, basically for every row we just set that value literally, and you'll see it on the screen. And the great thing about this is I can actually bind this property here to a SQL query to get data from a database, so I can get configuration there, and automatically set that. So we can add a row to the database table, which could automatically show that template here on the screen, making that screen very much dynamic. So this is a very powerful component and can really help you when you have a lot of repetition.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.