cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding a subform after selecting a value in dropdownlist

rameshkumar_ramasamy2
Participant
0 Kudos

Hi all,

I need to hide a subform if i select the first value in a dropdownlist. I have tried by hiding a button in it, its working properly but not for the subform. Please any one try to solve my issue.

I have worte the following coding in FARMCALC of CHANGE event in dropdownlist

if (xfa.event.newText == "1") then
xfa.form.data.SUB1.sub1_list.presence = "invisible"        /*Subform*/
xfa.form.data.SUB1.Button2.presence = "invisible"          /*Button hiding is working*/
xfa.form.data.SUB1.text.presence = "invisible"            /*Even TEXT hiding is not working*/
else
xfa.host.messageBox( xfa.event.newText )
endif

Thanks in advance..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Instead of change event , try writing the same code in the exit event of your dropdown field.

Also check the path for the subform as suggested above.

Thanks & Regards,

Omkar Mirvankar.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi There,

I am facing problem in Dropdown lists in Subforms.

I want the region dropdown list values according to country (only for DE) dropdown list value. Both Dropdown lists are in a Subform.

 

For that, I have used this in EXIT event of Country Dropdown list:

if (this.rawValue == "DE Deutschland")

{

data.Item.IT_ITEM.DATA.ZZ_REGION.clearItems();

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Schleswig-Holstein","1");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Hamburg","2");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Niedersachsen","3);

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Bremen","4");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Nordrhein-Westfalen","5");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Hessen","6");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Rheinland-Pfalz","7");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Baden-Württemberg","8");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Bayern","9");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Saarland","10");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Berlin","11");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Brandenburg","12");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Mecklenburg-Vorpomme","13");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Sachsen","14");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Sachsen-Anhalt","15");

data.Item.IT_ITEM.DATA.ZZ_REGION.addItem("Thüringen","16");

}

else

{

data.Item.IT_ITEM.DATA.ZZ_REGION.clearItems();

}

It does only change first region dropdownlist value, not others because both dropdown lists are in a Subform.

Other problem is that it works only when All Country Dropdown lists are "DE". Means, first region dropdown list depends upon not only first country dropdown but also other dropdown.

My requirement is, If first country Dropdown is "DE", only first Region Dropdown list should be fill, not others. And so on.

Please provide solution that How can I change all dropdown lists of a Subform dynamically?

Waiting for reply.

Thank you

Chandler Bing

Former Member
0 Kudos

Hi,

I assumed this is a form being used in HCM P&F. Do you trigger any roundtrip after user selected any dropdown value?

If yes, you should put the code in Initialize* event to hide/display any others field, but not change* event.

To check drop down value in intialize method, please use this.rawValue instead of xfa.event.newText.

Hope this helps. Thanks.

regards,

Xiang Li

Edited by: xiangli heah on Aug 3, 2010 10:56 AM

Edited by: xiangli heah on Aug 3, 2010 11:00 AM

rameshkumar_ramasamy2
Participant
0 Kudos

Hi

thanks for ur reply..

I have a drop down list with values. for eg 1 and 2.. If i select 1(i mean 1st value) from the dropdown, a subform (sub1_list) must go invisible. This is my scenario.. So i tried with that.. its not working..

I have worte the following coding in CHANGE event of dropdownlist

/* Here this code *xfa.event.newText* returns the selected value of the dropdownlist */

if (xfa.event.newText == "1") then
xfa.form.data.SUB1.sub1_list.presence = "invisible"        /*To hide Subform ( but not working )*/
else                                  /* If user selected other values in dropdown */
xfa.host.messageBox( xfa.event.newText )     /* For checking purpose i have displayed this as message*/
endif

Based on the user selection only, i need to hide a subform.. So i think we have to write in CHANGE event of dropdown..

Edited by: Rameshkumar Raamasamy on Jul 23, 2010 3:37 PM

Former Member
0 Kudos

Hello,

Did you try the same code in EXIT event of the dropdown ?

Also, try giving messageboxes at different levels just to see which statement it reaches to.

like:

In EXIT event,

if ( this.rawValue == "1" ) then

xfa.host.messageBox("1")

else

xfa.host.messageBox( "2" )

endif

Regards,

Omkar Mirvankar.

ChrisSolomon
Active Contributor
0 Kudos

Your coding is confusing.

1. The newText value you are checking is the DISPLAYED text.....not the true drop-down option value. You ok with that?

2. From your code, it looks like you have a subform in a subform (is "sub1_list" really your subform name?!?!) among other things. So it looks like you have

SUB1 (subform?)

++dropdownlist (the one you want event on)

++sub1_list

++button2

++text (this can NOT possibly be the name you gave a text element I hope!)

3. Also....if you hide the subform, it hides all elements in it (ie. you don't have to worry about hiding each one yourself.

Now, I am pretty sure that is no where close to what your actual SOM looks like. Your problem is most likely you are not using the correct SOM paths to your elements. You know there is a "shortcut" for how to have it automatically place the SOM path of an element into your script.......in the script editor, click to the place you want to inset (ie. hold the "I" beam there)....then hold down control key and move cursor onto your form onto the element you want path too....the cursor will become a "V"....then click....the SOM path will then be placed into your script. Past that, also look at the path it shows in the events for the element you want to control. You can select that path and paste it into your script as well. Both ways work.