Power Table add 2 columns value

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

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


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)

I am using this script to get selected rows from power tabel

my output

Row:  0 Col:  0     ColName:  Work order    Value:  2634
Row:  0 Col:  1     ColName:  Recipe    Value:  5/8 TYPE X 4X8 BA-K32
Row:  1 Col:  0     ColName:  Work order    Value:  2637
Row:  1 Col:  1     ColName:  Recipe    Value:  5/8 GLASROC TILEBCKR (CANADA) 4X8-K32
Row:  2 Col:  0     ColName:  Work order    Value:  2638
Row:  2 Col:  1     ColName:  Recipe    Value:  1/2 GLASROC TILEBCKR (CANADA) 4X8-K40
Row:  3 Col:  0     ColName:  Work order    Value:  2640
Row:  3 Col:  1     ColName:  Recipe    Value:  5/8 TYPE X 4X10 BA-K32

Actually i want to combine
Row: 0 Col: 0 and Row: 0 Col: 1 value like this

2634$5/8 TYPE X 4X8 BA-K32

same way for others also
Row: 1 Col: 0 and Row: 1 Col: 1 … goes on

how to achieve this can any one give me idea?

actually i have power table and i am selecting few rows
image

i want to combine first column data with $ symbol with second column data (note only with same row)

i dont know how to do that for inly selected rows only?

You can join the string values of the columns into a list. Then, join the list.

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

selectedRows = table.selectedRows

# Use for entire row:
# selectedColumns = xrange(table.getColumnCount())

# Use for selectedColumns
selectedColumns = table.selectedColumns

for row in selectedRows:
	dataList = []
	for col in selectedColumns:
		# Append the string value to the list
		dataList.append(str(table.getValueAt(row, col)))
	# Print the list
	print dataList
	# Print the joined list
	print '$'.join(dataList)
1 Like