# Get All Selected Cells in Power Table

**URL:** <https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [November 8, 2017, 7:18pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934 "2017-11-08T19:18:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [November 8, 2017, 7:18pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/1 "2017-11-08T19:18:30Z")

</div>

I have a power table which allows the user to select only the cells they want to selected in each column rather than entire rows. I need to get a dictionary or a dataset containing all of the cell values or else the indices that can be used to find the values of the selected cells.

I cannot find a way to get this information directly from the component or else add this functionality. If I need to add it, then I was thinking I could just add a tuple to a list in a custom property every time a new cell is selected and remove from this list when a cell is de-selected.

Is there any way I can accomplish this?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 8, 2017, 7:44pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/2 "2017-11-08T19:44:07Z")

</div>

Look at the [docs for the Power Table](https://docs.inductiveautomation.com/display/DOC79/Power+Table) under “Scripting Functions”: `getSelectedRows()`.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [November 8, 2017, 9:21pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/3 "2017-11-08T21:21:51Z")

</div>

If I have three rows selected in Column A and four rows selected in Column B, this method will return [0,1,2,3]. I need to know which rows are selected in each column.

---

<div class="post-metadata">

**Author:** ![zackscriven](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zackscriven/32/7213_2.png) [@zackscriven](https://forum.inductiveautomation.com/u/zackscriven)\
**Post date:** [November 8, 2017, 11:20pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/4 "2017-11-08T23:20:09Z")

</div>

You can use `getSelectedRows()` in combination with `getSelectedColumns()` to find the matrix cross product

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [November 8, 2017, 11:23pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/5 "2017-11-08T23:23:21Z")

</div>

Doesn’t seem like cross product is what OP wants…

If I have row 1 selected in Column A and row 2 selected in Column B, the cross product is (Column A, row 1), (Column A, row 2), etc.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [November 8, 2017, 11:29pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/6 "2017-11-08T23:29:21Z")

</div>

Probably going to have to do something like this pseudocode…

```python
table = getTable()
for row in getSelectedRows():
  for column in getSelectedColumns():
    if table.isCellSelected(row, column):
      print "hooray, selected!"

```

---

<div class="post-metadata">

**Author:** ![zackscriven](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zackscriven/32/7213_2.png) [@zackscriven](https://forum.inductiveautomation.com/u/zackscriven)\
**Post date:** [November 8, 2017, 11:35pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/7 "2017-11-08T23:35:20Z")

</div>

> [@KathyApplebaum](#):
>
> Doesn't seem like cross product is what OP wants...
> 
> If I have row 1 selected in Column A and row 2 selected in Column B, the cross product is (Column A, row 1), (Column A, row 2), etc.

Yeah, I was just joking while pointing to the fact that there is a getSelectedColumn method.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [November 8, 2017, 11:36pm UTC](https://forum.inductiveautomation.com/t/get-all-selected-cells-in-power-table/15934/8 "2017-11-08T23:36:01Z")

</div>

```auto
tableComponent = event.source.parent.getComponent('Power Table')
table = tableComponent.getTable()

selectedRows = table.getSelectedRows()
selectedColumns = table.getSelectedColumns()

for r in selectedRows:
	for c in selectedColumns:
		if table.isCellSelected(r,c):
			print "Row: ", r, "Col: ", c," ColName: ", table.getColumnName(c), " Value: ", table.getValueAt(r,c)

```
