# onMousepress issue when Power Table is filtered

**URL:** <https://forum.inductiveautomation.com/t/onmousepress-issue-when-power-table-is-filtered/37559>\
**Category:** General Discussion\
**Created:** [August 10, 2020, 5:19pm UTC](https://forum.inductiveautomation.com/t/onmousepress-issue-when-power-table-is-filtered/37559 "2020-08-10T17:19:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RForshey](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RForshey](https://forum.inductiveautomation.com/u/RForshey)\
**Post date:** [August 10, 2020, 5:19pm UTC](https://forum.inductiveautomation.com/t/onmousepress-issue-when-power-table-is-filtered/37559/1 "2020-08-10T17:19:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 10, 2020, 6:19pm UTC](https://forum.inductiveautomation.com/t/onmousepress-issue-when-power-table-is-filtered/37559/2 "2020-08-10T18:19:30Z")

</div>

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  
[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.14/com/inductiveautomation/factorypmi/application/components/VisionAdvancedTable.html#rowIndexToModelIndex(int)](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.14/com/inductiveautomation/factorypmi/application/components/VisionAdvancedTable.html#rowIndexToModelIndex(int))  
Usage would be something like:

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

```

---

<div class="post-metadata">

**Author:** ![RForshey](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RForshey](https://forum.inductiveautomation.com/u/RForshey)\
**Post date:** [August 10, 2020, 8:34pm UTC](https://forum.inductiveautomation.com/t/onmousepress-issue-when-power-table-is-filtered/37559/3 "2020-08-10T20:34:50Z")

</div>

```auto
	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? 🙂
