onMousepress issue when Power Table is filtered

Hello all!

I have a Power Table that displays data based on a SQL query. I’ve enabled onMousepress running this script:
data = system.dataset.toPyDataSet(self.viewDataset) self.PN = data[rowIndex]['Part ID']

Basically when the user clicks on a row, the Part ID in that row is then used to get data in a different table. It works exactly as intended, unless they filter the table! Simply just changing the order of a column will cause the onMousepress to select a Part ID from a different row than the one selected. Clearing the filters, it works properly.

So, the problem is onMousepress doesn’t work correctly if the table is filtered. Any ideas?

Tables generally are complicated when sorting and filtering come into play - that’s why the configureCell function gets two different column and row index parameters.
The table itself has some helpful methods to translate indexes from one “coordinate system” (for lack of a better term) to another - see
Usage would be something like:

data = system.dataset.toPyDataSet(self.viewDataset) 	
self.PN = data[self.rowIndexToModelIndex(rowIndex)]['Part ID']
	data = system.dataset.toPyDataSet(self.viewDataset)
	self.PN = data[self.rowIndexToModelIndex(rowIndex)]['Part ID']

I set it up just like that; still doesn’t work. I looked through the material in the link you provided and don’t really see anything other than what you provided. It still works correctly if no filters, but doesn’t work with filters. Any more ideas? :slight_smile: