Need Help Understanding a dropdown

I am just trying to display the selected item of a dropdown, the dropdown is being populated by a sql query. Right now there are two item in the dropdown, test1 and test 2.

I have the property change of the dropdown populated with “print event.source.selectedItem”

When i click between test1 and test2 the selectedItem gets printed three times on the screen and im not sure why?

My goal is to run a query of the selected item after it has been selected but i need to understand how it functions first, thanks!

The propertyChange event is triggered for every property that changes on a component. When you select a value, you are changing the selectedIndex, selectedValue, and selectedLabel at a minimum. You should use the event.propertyName property to limit when your changes are made:

if event.propertyName == "selectedIndex":
	#do something

That helps, I’m sure, but there’s an easier way to do what you want, I think. If you want to update a table query based on the selection, you only have to include a reference to the dropdown value in your query for the table:

table.data:

SELECT columns 
FROM tablename
WHERE fieldname = '{Root Container.Dropdown.selectedStringValue}'

Ignition will immediately refresh the table query when the value changes.

Thanks for the quick response, i actually want to run a separate query on a different table based on the value selected from the dropdown.

so i take it that since three items change that is why when i select an item it shows up three times? Thanks again

You should play with the code. See what happens when you do:

print event.propertyName

i guess since i wasn’t filtering anything out i was seeing all changes, ill play around a little more later. Thanks for your help! I appreciate it

where can i get a list of all of the property change events associated with them? thanks

[quote=“drewdin”]
so i take it that since three items change that is why when i select an item it shows up three times? Thanks again[/quote]
Yes, that is correct.

I don’t think there is any list availabe for “property change events”. You need to run “print event.propertyName” and modify the values of properties and see which ones get printed.

This from the Ignition Manual is helpful:

inductiveautomation.com/support/ ... _types.htm

Best,
Nick Mudge