Chris Bransden · Nov 17, 2021

zen dataCombo - setValue() not show correct displayValue

Hi All,

I'm having a strange issue where doing a .setValue on a ZEN datacombo is updating it with the value as-is, not the corresponding display value. Eg, if I connected it to query that returns two columns: ID,Name, and do a setValue(ID), I would expect the text in the datacombo to update showing Name. Instead it updates show ID, which I only want to use internally.

However, if I click on the dropdown, showing all the valid Names, select one, it works fine, showing Name (with the ID retrievable by getValue() as normal). Additionally, if I try a setValue(ID) AFTER the dropdown has been opened and closed, it works correctly also?! So I don't think it's a problem with the my SQL, but rather the state of the datacombo after pageload.

It's almost as if the SQL query is not run until the dropdown is clicked upon, so the 'displayValues' are not there to be utilised until after that. I've tried renderDropdown(), refreshContents(), etc, before I do my setValue(ID), but no luck. Is there some kind of attribute that could causing this issue, as I'm sure it wouldn't happen with a default datacombo?

I would supply my code but it's a very long, ugly unreadable mess I've inherited (which I'm sure is causing the issue), which I can't really lift out of context, so hopefully the problem is clear from the description!

Many thanks,


Product version: IRIS 2019.1
$ZV: IRIS for Windows (x86-64) 2019.1.1 (Build 612U) Mon Oct 28 2019 11:29:24 EDT
0 112
Discussion (2)1
Log in or sign up to continue

You're exactly right; by default, the contents of the dataCombo are empty until the user clicks on it, then the query gets executed. If you set the cached property of the dataCombo to 1, it'll load as soon as the page loads instead.

Thank you David! That was exactly it. Working great now!