How would I get a cell value from the Power Table on a row selection using a mouse?
I tried the mouseClicked event, but it fires after I click the row, then click on an empty section of the Power Table. So, now I am trying the onMousePress extension function, but it tells me that I cannot use:
table = event.source
val = table.data.getValueAt(...)
because it has no attribute data.
So then what? I have used this code on a normal Vision table...
The event object is referring to the mouse event. There is a value object that references the value of the clicked upon location. If that doesn't work for what you are attempting then you can use self.data, according to the manual a reference to the component is passed as self to the event.
Object value - The value at the location clicked on.
Component self - A reference to the component that is invoking this function.
Thanks Ryan.
Funny, I just figured out another way just as you replied, and combined the two here:
def onMousePress(self, rowIndex, colIndex, colName, value, event):
table = event.source
recipe = table.getValueAt(rowIndex, 0)
self.parent.selectedRecipe = recipe
data = self.data
val = data.getValueAt(self.selectedRow, 'RecipeID')
print val
Interestingly, using event.source I must use an integer valued index, but using self.data I can use the column heading as well.
event.source.getValueAt is calling the method on the actual JTable:
data.getValueAt is calling the method on Dataset, which is overloaded to accept column names as well:
Note that if you ever sort or filter the table data you'll have to account for that.