Get All Selected Cells in Power Table

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?

Look at the docs for the Power Table under “Scripting Functions”: getSelectedRows().

1 Like

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.

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

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.

Probably going to have to do something like this pseudocode…

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

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

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)