# Don't trigger table onRowClick when element in the subview is clicked

**URL:** <https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [November 1, 2024, 1:54pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043 "2024-11-01T13:54:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [November 1, 2024, 1:54pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/1 "2024-11-01T13:54:30Z")

</div>

Hi all,

I have an event script running in the onRowClick event of my table that

- Expands the row's subview, if it is closed, and collapses all others
- If the clicked row's subview is open, collapses it

**The problem** I am running into is that _when a component in the subview is clicked on, it is treating it as a row click and closing that subview_. I could simply change the script to not allow closing the subview by clicking a row, but I'd like to keep this in if possible so that the user does not have to click the small arrow icon every time.

Is there a way to achieve this?

Adding the onRowClick script below if it helps at all (the currentSubviewInd is a custom prop on the table that tracks the index of the currently opened subview).

```python
def runAction(self, event):
	self.collapseSubviews()

    # check if the clicked row is already open
	if (event.rowIndex != self.custom.currentSubviewInd):
		self.expandSubviews([event.rowIndex])
		self.custom.currentSubviewInd = event.rowIndex
	else:
        # reset custom prop
		self.custom.currentSubviewInd = -1

```

Thank you!

---

<div class="post-metadata">

**Author:** ![Nick\_Wilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick_wilson/32/80663_2.png) [@Nick\_Wilson](https://forum.inductiveautomation.com/u/Nick_Wilson)\
**Post date:** [November 1, 2024, 6:29pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/2 "2024-11-01T18:29:42Z")

</div>

Change your onRowClick event script to this:

```python
def runAction(self, event):
	self.expandSubviews([self.props.selection.selectedRow])

```

Make sure that the table property rows.subviewExpansionMode == "single"

**EDIT:** I reread your question and understand your problem now. I was able to replicate this and am not sure how to fix it.

I modified the onRowClick script to this:

```python
	if self.props.selection.selectedRow == self.custom.selected_row_old:
		self.collapseSubviews()
	else:
		self.expandSubviews([self.props.selection.selectedRow])
		self.custom.selected_row_old = self.props.selection.selectedRow

```

Clicking on the subview contents when the row is expanded collapses the subview no matter what I try. Not sure if there's a JS injection hack for this where you could target only the subview div

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f0752689636786a78d915bdda7439c5973b0899a.png)

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [November 1, 2024, 6:50pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/3 "2024-11-01T18:50:43Z")

</div>

Without thinking about scripting for a moment,

- Expands the row's subview, if it is closed, and collapses all others

Is there a reason you aren't changing the properties to single for subviewExpansionMode to achieve behavior like this? Then you just need the script to expand on row click in addition to the built-in arrow.

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [November 1, 2024, 7:07pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/4 "2024-11-01T19:07:18Z")

</div>

Yeah, I realized the table already had the single option for `subviewExpansionMode` and I was just doing extra work with that earlier. So I removed it, and the script now just a single line calling the `expandSubviews()` function for the selected row.

---

<div class="post-metadata">

**Author:** ![Nick\_Wilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick_wilson/32/80663_2.png) [@Nick\_Wilson](https://forum.inductiveautomation.com/u/Nick_Wilson)\
**Post date:** [November 1, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/5 "2024-11-01T19:08:03Z")

</div>

Are you fine with not being able to close the subview by clicking on the row header?

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [November 1, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/6 "2024-11-01T19:13:57Z")

</div>

Thanks for the feedback Nick,

That is pretty much where I am stuck at. I'm pretty satisfied with the result as is. Being able to close the subview on a row click is not a necessary thing, just would've been a nice ease-of-use feature for the screen.

Wanted to see if there was some simple fix for it, but I don't want to sink too much time or effort into it.

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [November 1, 2024, 7:33pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/7 "2024-11-01T19:33:55Z")

</div>

My bad, the behavior we are looking to avoid is the subview clicking to close, I am not sure how to avoid that I think what you have may be the best solution.

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [October 2, 2025, 9:37pm UTC](https://forum.inductiveautomation.com/t/dont-trigger-table-onrowclick-when-element-in-the-subview-is-clicked/98043/8 "2025-10-02T21:37:01Z")

</div>

I have been having problems with this too, so I put in a feature request ([link](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/change-onrowclick-event-such-that-it-does-not-fire-when-clicking-within-row-subv)).
