# Perspective Table Context Menu - activated rowData

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-context-menu-activated-rowdata/96051>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [September 17, 2024, 7:08am UTC](https://forum.inductiveautomation.com/t/perspective-table-context-menu-activated-rowdata/96051 "2024-09-17T07:08:25Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 19, 2026, 8:58pm UTC](https://forum.inductiveautomation.com/t/perspective-table-context-menu-activated-rowdata/96051/13 "2026-08-19T20:58:12Z")

</div>

Since I absolutely needed this right now, was able to do it via following code.

```python
prop_name = "selected_row" #this is the page custom property to write value to.
code = """<img style='display:none' src='/favicon.ico' onload=\" const view = [...window.__client.page.views._data.values()].find(v => v.value.mountPath == this.parentNode.parentNode.parentNode.getAttributeNode('data-component-path').value.split('.')[0]).value; const tableId = '#"""+str(value)+"""'; let highlightedRow = null; function setHighlight(row) { if (highlightedRow && highlightedRow !== row) { highlightedRow.style.outline = ''; highlightedRow.style.backgroundColor = ''; } if (row) { row.style.outline = '2px solid #2684FF'; row.style.backgroundColor = 'rgba(38, 132, 255, 0.12)'; } highlightedRow = row; } function getRowIndex(row) { const explicitIndex = row.getAttribute('data-row-id'); if (explicitIndex !== null) { return parseInt(explicitIndex, 10); } const ariaIndex = row.getAttribute('aria-rowindex'); if (ariaIndex !== null) { return parseInt(ariaIndex, 10) - 1; } const allRows = Array.from(document.querySelectorAll(tableId + ' .ia_table__body__row')); return allRows.indexOf(row); } function onContextMenu(event) { const row = event.target.closest('.ia_table__body__row'); if (!row) { return; } setHighlight(row); const rowIndex = getRowIndex(row); const cell = event.target.closest('[data-column-id]'); const columnId = cell ? cell.getAttribute('data-column-id') : null; view.custom.write('"""+prop_name+"""', {row_index: rowIndex, column_id: columnId}); } function attach() { document.querySelectorAll(tableId).forEach(function (table) { table.addEventListener('contextmenu', onContextMenu, true); }); } attach(); setTimeout(attach, 300); setTimeout(attach, 800); \"></img>""".replace("\n", "").replace("\t", "")
return code

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/e/aed91a11b77013855724e6379ee3126fcccb933e.png)

Special thanks to @victordcq for [Javascript inject in Perspective](https://forum.inductiveautomation.com/t/javascript-inject-in-perspective-have-fun/65805)

Hope this saves tiny amount of time to someone in future.

Cheers !!

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-table-context-menu-activated-rowdata/96051)._
