I have created a dropdown box in perspective. The basic operation is to add options dynamically based on a variable. The first thing the script does is clear out all of the options except of an All option and then populates the rest of the options. For some reason only option 2 and option 6 have this issue, I have expanded it out to have 30 different options. When selecting either option 2 or option 6, both will highlight but it ends up only passing the value from 2. This does not happen when using the play button in the designer only when online with the web address. I have closed and reopened the screen a number of times. Any suggestions on how to fix this issue?
Below you will find an image of the double selection as well as my script. To be clear the property multiselect is false and unbound.
Script:
def runAction(self, event):
#Deletes the previous options upon startup
i = len(self.props.options)
while i > (self.view.custom.PB - 1):
del self.props.options[(i-1)]
i -= 1
#Creates new options until the length is 1 option longer than the desired number
if len(self.props.options) < (self.view.custom.PB + 1):
i = len(self.props.options)
while i < (self.view.custom.PB + 1):
#Adds all condition
if i ==0:
option = {
"value": (int(i)),
"label": "All",
}
self.props.options.append(option)
#Logic to creat new conditions based on dynamic input value
elif i > 0:
#Adds conditions less than 10 with leading 0 for formatting (displays a 2 digits)
if i<9:
option = {
"value": (i),
"label": "PB0" + str(i),
}
self.props.options.append(option)
#Adds conditions greater than 10 without leading 0 for formatting (displays a 2 digits)
elif i>=9:
option = {
"value": (int(i)),
"label": "PB" + str(int(i)),
}
self.props.options.append(option)
i += 1
I do believe this has less to do with the script and more to do with some weird bug/setting because as I stated it works great in the ignition designer, only has this issue when I go to launch it in the web session.
I meant you to post the JSON as code, not as a picture, but as it turns out we can see that you have individual bindings on options.0.value and options.6.value.
What's going on there?
You can remove them with Right-click → Remove Binding but inspect them first to see what they're doing.
An easy way to see what's going on would be to place a change script on Dropdown.props.value, where you print out the full list of options during selection (value change). Then you can look at what options "2" and "6" have as their value. Smart money is on them having the same value at that point in time - likely from your binding.
That's the part that was confusing me. When in the designer I can see they have two different values under their Dropdown.props.value, yet when I am in the main web address they are showing as if they hold the same value. I restarted the ignition service this morning and now everything is working as expected. Not sure why this was occurring but issue resolved.
Don't use the Designer for "vetting" of behaviors as it is not always a very good facsimile of a browser session. You'll find that some scripts run in different scopes, references to pages are completely different between the two, and certain function calls have no effect (Popups, Navigation, Docked Views).
People often run into "it doesn't work like that in a Session/Designer", and it's most often because something about a binding or script returns different values when run from a proper session.
And NEVER mix scripts with bindings to populate a single piece of data!
Bindings are removed. I had options six bound to int(6) just to cut it out as a possibility and I had 0 bound to int(0). Both have been removed, maybe that played a part in the issue if scripts and bounds do not play well together