# CheckBox Template repeater

**URL:** <https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [October 29, 2022, 9:24am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832 "2022-10-29T09:24:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [October 29, 2022, 9:24am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/1 "2022-10-29T09:24:45Z")

</div>

Hi,

I would like to use checkbox as a template in vision and it will be repeated as per the selection in a radio button.

For eg: If i have selected 'Equipment Failure' , i should be able to select only one option from subcategory which is a repeater.  
Currently multiple selection is possible which i would like to restrict.  
Any ideas to achieve this?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 29, 2022, 10:10am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/2 "2022-10-29T10:10:15Z")

</div>

Radio buttons are tied to each other if they're in the same container. Because yours are all container in their own template, they are all independent. I don't think you'll be able to use the default functionality, you will probably need to read the current state into your radio button template and fire a script to deselect the buttons that aren't on

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 29, 2022, 10:26am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/3 "2022-10-29T10:26:58Z")

</div>

Add this script to your checkbox's actionPerformed script, and you should get the effect you want:

```auto
for component in event.source.parent.parent.getComponents():
	for subComponent in component.getComponents():
		if subComponent != event.source:
			subComponent.selected = False

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 29, 2022, 10:31am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/4 "2022-10-29T10:31:22Z")

</div>

> [@Dharani\_T](#):
>
> i should be able to select only one option from subcategory which is a repeater.

Using checkboxes for that functionality is bad GUI design and will cause confusion.

- Radio buttons are "interlocked" and one and only one can be selected.
- Checkboxes are independent and multiple (or none) can be selected.

You should be using radio buttons for the sub-categories as well.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 29, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/5 "2022-10-29T13:36:37Z")

</div>

I totally missed the mention of check boxes, haha. I just assumed they were radio buttons.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 21, 2023, 8:58am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/6 "2023-02-21T08:58:27Z")

</div>

Hi ,

**same script i tired for radio button its not working**

anything needs to be alter for radio button?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 21, 2023, 9:18am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/7 "2023-02-21T09:18:07Z")

</div>

Is your radio button in a template repeater?

If so, is it in a nested container within the template?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 21, 2023, 9:26am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/8 "2023-02-21T09:26:23Z")

</div>

i have one radio button in template

i am calling template in template repeater (repeater placed in root container of window) and given count 5.

but when i switch from one radio button to another its not deselecting

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 21, 2023, 9:54am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/9 "2023-02-21T09:54:06Z")

</div>

You're running into a fundamental radio button behavior. The template acts as a container, so without another radio button in the template, the `setSelected` method is not going to work without some creative hocus pocus.

A simple way to do it would be to put a second radio button with a special name in the template with the visibility set to false, and then programmatically set the invisible radio button to `setSelected(True)` to deselect the visible radio button

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 21, 2023, 11:14am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/10 "2023-02-21T11:14:14Z")

</div>

@prasath.t:

Okay, I've tested the below script, and it works. If you name your invisible radio button: 'invisibleButton', and put the following script on the **VISIBLE** button's actionPerformed event handler, it will give you the result you are looking for:

```auto
rootButton = event.source.parent.getComponent('invisibleButton')
for component in event.source.parent.parent.getComponents():
	for subComponent in component.getComponents():
		if subComponent != rootButton and subComponent.name == 'invisibleButton':
			subComponent.selected = True

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 21, 2023, 11:16am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/11 "2023-02-21T11:16:10Z")

</div>

thank you so much

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 22, 2023, 7:32am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/12 "2023-02-22T07:32:03Z")

</div>

Hi @justinedwards.jle

one question  
i have 3 check box in template repeater  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/7/57009e0de0499a3781e7575a303186eca5696ab9.png)

i want them to be align from center

but it starting from right top

i justed the flow direction also but it's not changing anything i am missing here?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/1/214edf1b0b1d7566c3fcdb6c8bc19434f2fa9aa1.png)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 22, 2023, 7:35am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/13 "2023-02-22T07:35:22Z")

</div>

Got it this is the setting we need to use  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c640ac3dcf502268b11ee53be1ee8913c549232d.png)

@justinedwards.jle

how to fetch the **selected button name from template repeater**?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c540f5451e03f35248de67f5fdb212ca5b78a3f2.png)

example -  
in my image matline selected.. i want to fetch that name  
i tired but don't know how to get it

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 22, 2023, 9:02am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/14 "2023-02-22T09:02:16Z")

</div>

From where or when are you wanting to get it?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 22, 2023, 9:05am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/15 "2023-02-22T09:05:09Z")

</div>

> [@justinedwards.jle](#):
>
> 'invisibleButton

when selection changes. i planning to get it in template repeater property change.

is there any better way to get it.. i really don't know

based on the selection name i need to run some script that's is my goal

**it's good to get it in template repeater custom property**

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 22, 2023, 9:16am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/16 "2023-02-22T09:16:39Z")

</div>

> [@prasath.t](#):
>
> when selection changes

It's not the name you're after; it's the text. Assign it to your custom property from the VISIBLE button's actionPerformed event script. It will simply be: `event.source.text`.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 22, 2023, 9:22am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/17 "2023-02-22T09:22:19Z")

</div>

yes i need the text based on the selection change

**but i didn't getting what you ask me to do**

when selection changes nothing is happening in template repeater property. that's why i don't know how to fetch it

if write the script in template action performed but how to right back that to template repeater custom property?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 22, 2023, 9:27am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/18 "2023-02-22T09:27:46Z")

</div>

You have a custom property on the template REPEATER?

What is it called, and what datatype is it?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 22, 2023, 9:29am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/19 "2023-02-22T09:29:23Z")

</div>

workshopName (string datatype)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 22, 2023, 9:32am UTC](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832/20 "2023-02-22T09:32:11Z")

</div>

The template is the button's parent, and ~~the repeater is the template's parent~~ , so the code will look like this:

```auto
event.source.parent.parent.parent.parent.parent.workshopName = event.source.text

```

**Edit:** Oops! @prasath.t, I just tested it, and the parent of the template is actually the scroll pane. You'll have to go a few layers higher to get to the repeater. I've corrected the code accordingly.

[Next page](https://forum.inductiveautomation.com/t/checkbox-template-repeater/65832.md?page=2)
