Since I absolutely needed this right now, was able to do it via following code.
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
Special thanks to @victordcq for Javascript inject in Perspective
Hope this saves tiny amount of time to someone in future.
Cheers !!
