Set default value of (dynamic content) listbox

I have four dropdown lists on a popup window. The datasets are two column, i.e. an integer value and a description.
When the window’s opened I want to set the default selections on these dropdown lists.
I have a custom property dataset on the popup that contains the default values and I am binding the selectedValue property of each
dropdown list to the relevant value in the dataset.

It works for the first list but not for the others (I just see the integer numbers rather than the corresponding descriptions)
and that’s sort of helped diagnose the problem.

The issue is that the contents of each dropdown list depend on the selection in the one above it. So the Data property of each one is an SQL query
which includes a filter based on the selectedValue of the one above it.

I’m guessing there’s some sort of timing issue where it’s trying to set the selectedValue but before the list has
been fully populated with all the options?

Does that makes sense and has anyone got any workarounds? (maybe using timer controls to allow for the list update
before selecting a value etc?)

You could try wrapping your code around a function and call the function asynchronously:

#define this in an asynch so we get the current value instead of teh prev value
def doAsynch(event=event):
	import system
	[...snip...]
system.util.invokeAsynchronous(doAsynch)

Sometimes that allows piped events to go through first before your code does.

Can you expand on that at all?
At the moment I have no code (as in script).
It’s all done on binding.

Hmm, I misunderstood. I might be better to first try to make sure your Polling Mode is Relative for your bindings. That may solve the problem within milliseconds.

Just tried that idea and thought for a moment that it had solved the problem.

But unfortunately it hasn’t. Unless I close the window and open it with the same selections in, I’m still getting the same issue as before.

You’ll want to set the Polling Mode to Off for all your dropdown list queries. Your queries will fire when the window is first opened and any time a bound value within the query changes i.e. the selected value of one of the other dropdown lists changes.

My first guess is that you are programmably setting the default values of the dropdown lists when the window is opened but the selectedValue change event isn’t firing because the selectedValue didn’t change, in other words you saved the project with the default values, so when the window opens and your code sets the default values, nothing changes because they are already that value.

I would first set the selectedValue properties to -1 in all the dropdown lists and then save the project, then try opening it up in the client. If that doesn’t change anything then I would check if it’s a timing issue by putting a button on the window that sets the selectedValue of one of the dropdown lists to something and see if that does anything.

Even putting a button on which set all the selectedValues didn’t work. What was happening was my lists actually ended up with the right things in them (each list is based on the selected value above) but the value being displayed was actually the ID number (i.e. the value) rather than the description. I suspect this is because I was setting the selectedValue before the list had had a chance to populate from the database and thus the value couldn’t be translated into a description.

Anyway I believe I’ve found a fix. I’ve put the following code on the propertyChange event of each dropdown:

if event.propertyName=="data": if event.source.data.rowCount>0: event.source.selectedValue=event.source.selectedValue
The “data” property change fires once the dataset has updated, at which point I effectively “refresh” the selectedValue. Because it now has its list it can find the value.

Hi Inductive Team,

I have a simular problem and no of those solutions help me. I use in a pupup window a Dropdown List with a SQL property binding, to load a list. If I open the popup, I peset the values on that popup by calling a script from internalFrameActivated.
It works for textFiels but not for the Dropdown list. If I close the pupup and open it again, it works. So I guess the first time the query did not read the record, before I try to set the values. (Selection mode is Strict).
What can I do?

Thanks’ for your support
Regards
Mike