How to hide a Drop-down (Choice list) when it's empty?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2018 12:54 AM
Hi ALL,
I have 2 drop-downs with a parent-child relationship:
- Drop-down 1 is parent
- Drop-down 2 is child (depends on Drop-down 1)
When parent's value is changed, child's values are populated automatically using Dictionary configuration (not Client Script).
Question 1:
For example:
Drop-down 1 has values: A, B and C
When drop-down 1's value is set as A, drop-down 2 is populated with: -- None --, X and Y
When drop-down 1's value is set as B, drop-down 2 is populated with: -- None -- and Z
When drop-down 1's value is set as C, drop-down 2 is populated with: -- None -- only (NO value is set)
When child is empty (only with -- None -- value), I want to hide child drop-down. Otherwise, I want to show it. Any ideas guys?
Question 2:
When using both Dictionary configuration and Client script (Type = onChange) on the same drop-down, the execution order is Client script > Dictionary configuration.
For example:
Drop-down 1 has values: A, B and C
When drop-down 1's value is set as A, drop-down 2 is populated with:
- X, Y, Z by Dictionary configuration
- X', Y', Z' by Client script
=> Client script is executed first, then Dictionary configuration. As a result, Drop-down 2 is populated with X, Y, Z
Can I switch or control the order of this behavior. I want Dictionary configuration is executed first, then Client script. Is it possible?
Many thanks,
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2018 12:57 AM
Hi,
If you choose child as none, it will hide but if you want to change value then how can you accesss it?
Thank you,
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2018 01:07 AM
Sorry, I updated my question more clearly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2018 03:08 AM
Hi,
For Question 1: You can hide child drop down to add condition on onChange client script based on parent drop down, when 2nd drop down is empty.
For example:
onChange of parent drop down
if(g_form.getValue('child')=='')
g_form.setDisplay('child',false);
else
g_form.setDisplay('child',true);
For Question 2: We modify our client script to achieve expected behavior.
If you can share your code snippet that would be better to elaborate.
Regards,
Jyoti soni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2018 07:11 PM
Hi Jyoti,
Thanks for your reply.
For question 1, I used Dictionary configuration for 2nd Drop-down based on the 1st Drop-down. As I mentioned in question 2, onChange() is always executed first, so the 2nd Drop-down is always empty inside onChange script before it's populated by Dictionary. So, your script will always hide 2nd Drop-down because the data is populated after onChange script.
For question 2, I haven't coded anything so far. I just want to ask.
--------------------
Anyway, because I have many levels of Drop-down (1st, 2nd, 3rd, until 7th) and they all have parent-child relationship. The choices are not fixed and large (up to a few hundred items), in the future, I need to add more based on business change. That's why I used Dictionary configuration instead of Client script for simplicity.
The issue is I just want to hide the Drop-down without any values inside (only have -- None --) same as question 2 I mentioned before. I don't want to use script because I have to change it a lot in the future if the new values are inserted. I'm looking for if there is a simple solution to hide empty Drop-down.