# Disabling right click option on the Report Viewer

**URL:** <https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104>\
**Category:** Ignition\
**Created:** [November 28, 2018, 5:20am UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104 "2018-11-28T05:20:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajesh.dayala](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rajesh.dayala](https://forum.inductiveautomation.com/u/rajesh.dayala)\
**Post date:** [November 28, 2018, 5:20am UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/1 "2018-11-28T05:20:31Z")

</div>

Hi Team,

I want to know how to disable export to Excel(or csv or pdf) option on the Report Viewer when we right click on it?

Is there a option in the versions from 7.9.6?

---

<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:** [November 28, 2018, 4:18pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/2 "2018-11-28T16:18:48Z")

</div>

To remove the entire popup menu:

```auto
from org.apache.commons.lang3.reflect import FieldUtils
reportViewer = event.source.parent.getComponent('Report Viewer')
FieldUtils.writeField(reportViewer, "popupMenu", None, True)

```

If you want more granular control, you’ll have to dive into the `popupMenu` field and modify the JMenu there.

---

<div class="post-metadata">

**Author:** ![rajesh.dayala](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rajesh.dayala](https://forum.inductiveautomation.com/u/rajesh.dayala)\
**Post date:** [November 29, 2018, 10:52am UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/3 "2018-11-29T10:52:03Z")

</div>

Hi paul,

Thanks for your immediate response, But can you please tell me Where can i find/Run the scripts to make the adjustments.  
Actually i want to disable only save as XLS Option from Report viewer.

Thanks  
Rajesh

---

<div class="post-metadata">

**Author:** ![rajesh.dayala](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rajesh.dayala](https://forum.inductiveautomation.com/u/rajesh.dayala)\
**Post date:** [December 5, 2018, 6:30am UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/4 "2018-12-05T06:30:34Z")

</div>

Hi Paul,

Can you send me the updated script below which only removes the **Save as XLS** option from the PopupMenu?

FieldUtils.writeField (reportViewer, “popupMenu”, None, True)

---

<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:** [December 5, 2018, 4:25pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/5 "2018-12-05T16:25:51Z")

</div>

I don’t have the code written, but here’s what you would need to do:

1. Use [`FieldUtils.readField`](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/reflect/FieldUtils.html#readField-java.lang.Object-java.lang.String-boolean-) to get the current value of the `popupMenu` field, which will be a [`JPopupMenu`](https://docs.oracle.com/javase/8/docs/api/javax/swing/JPopupMenu.html).
2. Go through each sub element on the menu with [`getSubElements()`](https://docs.oracle.com/javase/8/docs/api/javax/swing/JPopupMenu.html#getSubElements--)
3. Find the menu item that represents the ‘Save as XLS’ option - you will probably need to `getComponent()` on each menu item, then check its defined text (`getText()`)

---

<div class="post-metadata">

**Author:** ![rajesh.dayala](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rajesh.dayala](https://forum.inductiveautomation.com/u/rajesh.dayala)\
**Post date:** [December 10, 2018, 3:52am UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/6 "2018-12-10T03:52:36Z")

</div>

> [@paul-griffith](#):
>
> FieldUtils.readField

Thank you i will try this 🙂

---

<div class="post-metadata">

**Author:** ![rrindahl](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@rrindahl](https://forum.inductiveautomation.com/u/rrindahl)\
**Post date:** [May 8, 2019, 12:47pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/7 "2019-05-08T12:47:21Z")

</div>

Paul,  
I have a project where the “Export to Excel” option from the reporting pop-up menu is locking the customers computers. They have requested that the entire pop-up menu be disabled. I tried adding the code you suggested above to the onReportGenerated portion of the report viewer component, but it did not disable the menu.  
Could you elaborate on where the code should be placed and if I need to install anything on the gateway computer to get this to work.  
Thanks.

---

<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:** [May 8, 2019, 3:19pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/8 "2019-05-08T15:19:30Z")

</div>

Put it on `windowOpened` or `internalFrameActivated` and change the component reference accordingly. You need it to run at least once as soon as the window starts up, so that the component has no popup menu - the `onReportGenerated` function is probably firing too “late” in the process.

---

<div class="post-metadata">

**Author:** ![rrindahl](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@rrindahl](https://forum.inductiveautomation.com/u/rrindahl)\
**Post date:** [May 8, 2019, 6:42pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/9 "2019-05-08T18:42:31Z")

</div>

Thank you. internalFrameActivated did the trick.

---

<div class="post-metadata">

**Author:** ![boyergary](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/boyergary/32/10316_2.png) [@boyergary](https://forum.inductiveautomation.com/u/boyergary)\
**Post date:** [October 25, 2019, 6:10pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/10 "2019-10-25T18:10:00Z")

</div>

I needed this functionality, so I wrote a little segment of code that will allow you to easily remove any of the right-click print options you don’t want. You just need your reference to the Report Viewer and a collection of actionOptions that you want on the right-click menu (spelling and capitalization must be exact!) Based on PGriffith’s recommendation above.

```
from org.apache.commons.lang3.reflect import FieldUtils

actionOptions = ["Print", "Save as PDF", "Save as XLS", "Save as HTML", "Save as PNG"]

if len(actionOptions) <> 0:	
	popupMenu = FieldUtils.readField(reportViewer, "popupMenu", True)
	menuItems = popupMenu.getSubElements()
	for count in range(len(menuItems)-1, -1, -1):
		if menuItems[count].text not in actionOptions:
			popupMenu.remove(count)
```

---

<div class="post-metadata">

**Author:** ![melwadeya](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@melwadeya](https://forum.inductiveautomation.com/u/melwadeya)\
**Post date:** [May 4, 2020, 4:40pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/11 "2020-05-04T16:40:43Z")

</div>

Thanks for sharing this with us.

I am trying to have this working but keep getting the error:

 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/470324ab6e400ca88175f346a0e4a00e6736fac9.png)

note: I added the following line to reference the report viewer:  
reportViewer = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.My\_Report’).name

any advise?

Thanks in advance

---

<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:** [May 4, 2020, 4:42pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/12 "2020-05-04T16:42:57Z")

</div>

Drop the `.name`; you’re referencing the component correctly, but then getting its name, instead of the component itself.

---

<div class="post-metadata">

**Author:** ![melwadeya](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@melwadeya](https://forum.inductiveautomation.com/u/melwadeya)\
**Post date:** [May 4, 2020, 4:47pm UTC](https://forum.inductiveautomation.com/t/disabling-right-click-option-on-the-report-viewer/21104/13 "2020-05-04T16:47:15Z")

</div>

Thanks for the swift response, it is working now.
