IA Forum,
I have a change script on a Dropdown. Based on the value of the Dropdown (7, '7A' or 'All') the Perspective page will display a different Table. This is working as intended.
I also have a Button on the same page that triggers a Report Preview popup. I want the Report Preview to change based on the Dropdown Value. It currently pulls the 'All" report. If '7' is selected in the dropdown, then I want to Preview the '7' report. Likewise for the '7A' report.
How do i incorporate the existing change script to include the configured event on the Preview Report Button?
Here is my change script:
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
if currentValue.value == 7:
path = "Refrigeration/ChillerLog 7"
data = system.db.runNamedQuery(path)
self.getSibling("ChillerWOLog").props.data = data
elif currentValue.value == '7A':
path = "Refrigeration/ChillerLog 7A"
data = system.db.runNamedQuery(path)
self.getSibling("ChillerWOLog").props.data = data
else:
path = "Refrigeration/ChillerLog"
data = system.db.runNamedQuery(path)
self.getSibling("ChillerWOLog").props.data = data type or paste code here
OR,
Should three different buttons be configured with Visibility based on the value of the dropdown?
Make a custom property on the root container of the view, or on the view itself called selectedReport. Bidirectionally bind this custom property to the selectedValue of the dropdown.
You can then have a single button that has an if else statement check the value of the custom property and then open the appropriate popup
Create a custom property on the view's root and make a bidirectional binding on the dropdown value property to the custom prop. Then examine that in your script. (Ryan posted as I was typing.)
There is a minor problem with referencing the self.getSibling("Dropdown").props.value in your script. If you ever move either the dropdown or the button, rename it, or wrap either in a container then the script will break. Using a custom property on the view to link the two items together (as I suggested above) makes the application a lot less 'brittle' as both components can read and write to it and its path will always remain the same.
I would convert the dropdown's values to objects so that you can return multiple values for each selection. Then, you just return the path that you want as appropriate, and your script can be more generic. Something like:
I'd get rid of the value change script entirely.
As @lrose said, configure your dropdown's values to contain the data you need.
Then use the dropdown's onActionPerformed event to open the popup based on the current value (which is accessible easily from the event).