# Getting a list of contents of a Group

**URL:** <https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471>\
**Category:** Ignition\
**Created:** [May 19, 2014, 11:15pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471 "2014-05-19T23:15:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [May 19, 2014, 11:15pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/1 "2014-05-19T23:15:03Z")

</div>

I am trying the following:  
I have grouped together 3 checkboxes (and I intend to add many more checkboxes into this group). Users will be selecting one or more of these checkboxes. Based on their selection, I need to be able to obtain the name of the selected checkboxes.

For example, a user has selected 2 of the 3 checkboxes as shown in the attached picture. So, by a click of a button, I need to be able to get the names – ‘ActualRotationSpeed’ and ‘StepNumber’ printed on the output. What script can I write for that button to achieve that?

I need something like this – but don’t know the actual syntax -  
For each row in event.source.parent.getComponent(‘Group’).name:  
Print name of the Checkbox

Also, I want to create ‘Select All’ and ‘Deselect All’ buttons so that users can select or deselect all the checkboxes at the same time. What script can I use for these two buttons to achieve that?

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 20, 2014, 12:20am UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/2 "2014-05-20T00:20:12Z")

</div>

you may be better off using a table component for what you want to do. you could easily do what you want using the table component. you can run thru the dataset to grab which ones are selected easily and also select/deselect all.

---

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [May 20, 2014, 12:54am UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/3 "2014-05-20T00:54:38Z")

</div>

Thank you very much! I tried the table component. I was able to get the names – ‘ActualRotationSpeed’ and ‘StepNumber’ printed on the output using the following code:  
selectiondata = event.source.parent.getComponent(‘Selection Table’).data  
selectionrows = event.source.parent.getComponent(‘Selection Table’).selectedRows  
count = len(selectionrows)  
for row in range(selectiondata.rowCount):  
for i in range(len(selectionrows)):  
if selectiondata.getValueAt(row, “Selection”) == 1:  
print selectiondata.getValueAt(row, “Trace”)

However, I am running into a problem when I create the Select All button. I use the following code for that:  
selectiondata = event.source.parent.getComponent(‘Selection Table’).data  
for row in range(selectiondata.rowCount):  
selectiondata.setValue(row,“Selection”,1)

I am hoping that the setValue function will assign a value of 1 (i.e. True) for all the rows - making all of them ‘selected’. But I get an error message attached in the screen capture

What function can I use if setValue is not a valid function?

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 20, 2014, 1:21am UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/4 "2014-05-20T01:21:28Z")

</div>

This is how I did this the other day. My username, email comes from my database, but I create the selected column. same principle, just slightly different…

This would be when the screen loads and if someone clicks the clear all button

```auto
res = system.db.runQuery("SELECT username, email from users order by username")
header = ["Username", "Email", "Selected"]
newData = []

for row in res:
	newData.append([row[0], row[1], False])
	

event.source.parent.getComponent('Table').data = system.dataset.toDataSet(header, newData)
```

This would be to select all

```auto
res = system.db.runQuery("SELECT username, email from users order by username")
header = ["Username", "Email", "Selected"]
newData = []

for row in res:
	newData.append([row[0], row[1], True])
	

event.source.parent.getComponent('Table').data = system.dataset.toDataSet(header, newData)
```

Here is a sample of print the selected columns

```auto
emailDS = system.dataset.toPyDataSet(event.source.parent.getComponent('Table').data)
emailList = []
for row in emailDS:
	if row[2] == True:
		print row[1] + ' Selected'
```

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 20, 2014, 1:18pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/5 "2014-05-20T13:18:40Z")

</div>

also, you can turn off the border, header and horizontal/vertical lines on the table component and change the background/row selection color to match your window background. Like that, you wont be able to tell the difference between the table and the check box component.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [May 20, 2014, 3:38pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/6 "2014-05-20T15:38:54Z")

</div>

Since [setValue](http://inductiveautomation.com/support/usermanuals/ignition/tables_pmitable.htm) is a method of the table, you could try:

```auto
selection = event.source.parent.getComponent("Selection Table")
for row in range(selection.data.rowCount):
	selection.setValue(row, 0, 1)
	
```

---

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [May 20, 2014, 9:40pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/7 "2014-05-20T21:40:09Z")

</div>

Thank you very much! I tried this code suggested by adamaustin and it worked perfectly for me.

selection = event.source.parent.getComponent(“Selection Table”)  
for row in range(selection.data.rowCount):  
selection.setValue(row, 0, 1)

Thanks!

Shreyas

---

<div class="post-metadata">

**Author:** ![glogue](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@glogue](https://forum.inductiveautomation.com/u/glogue)\
**Post date:** [March 26, 2015, 3:29pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/8 "2015-03-26T15:29:35Z")

</div>

To do this with a script in a button, you can to the following:

I made a group in the Root Container called Group and it has three CheckBox components

Select all button

```auto
group = event.source.parent.getComponent('Group').components
for components in group:
	components.selected = 1 #set selected to true (select all checkboxes)
```

Deselect all button

```auto
group = event.source.parent.getComponent('Group').components
for components in group:
	components.selected = 0 #set selected to false (deselect all checkboxes)
```

Button to print the names of only the selected checkboxes

```auto
group = event.source.parent.getComponent('Group').components
for components in group:
	if components.selected == True:
		print components.name #name of the CheckBox component in the Project Browser
		#print components.text #name of the CheckBox as it shows where they check or uncheck boxes
```

---

<div class="post-metadata">

**Author:** ![Ros\_Alexander](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ros\_Alexander](https://forum.inductiveautomation.com/u/Ros_Alexander)\
**Post date:** [March 6, 2022, 11:19am UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/9 "2022-03-06T11:19:38Z")

</div>

How could I do this same thing but with Radio Buttons?

---

<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:** [March 6, 2022, 12:42pm UTC](https://forum.inductiveautomation.com/t/getting-a-list-of-contents-of-a-group/8471/10 "2022-03-06T12:42:29Z")

</div>

You don’t need to. This question is about check boxes of which operate independently so multiple values can be on at once. You are asking about radio buttons and this has been addressed in answers to your other question, [Radio Button Group Selected - #10 by Ros\_Alexander](https://forum.inductiveautomation.com/t/radio-button-group-selected/56852/10).
