cancel
Showing results for 
Search instead for 
Did you mean: 

Dependable Dropdown boxes.

Former Member
0 Kudos

Dear SDN Community,

I am looking for some suggestions to design dependable drop down boxes in WDJ. I have 5 drop down boxes. The values inside the second drop down box are dependent on first, third dropdown on second and so on. Can you please suggest a good design here for me.

Thanks!

Vivek.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

I would suggest an onSelected Action for each drop down box which cover the data handling for the next dropdown box.

E.g. onDropDown1Selected() -> produce data for type binded to drop down2 / onDropDown2Selected() -> produce data for type binded to drop down3 and so on. It is a bit more code to write instead of using one method to cover all the selected events but you can avoid figuring out from which drop down the selected event came.

Kind regards

Thierry

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi, could you explain in detail what kind of dependency are you referring to?

😃

Former Member
0 Kudos

Julio,

Imagine you have 3 drop down boxes for Country, State and City. In the Country dropdownbox if the user selects USA, it should list the US states in the second dropdown box, if he selects Canada, it should list only Canadian states. Once he selects the state in the second drop down, it should list the Citie's inside that state only. If the user selects country as USA and I dont want the user an option to select the Canadian state Ontario. Hope you understand my concern.

Thanks!

Vivek.

0 Kudos

Vivek,

This can be easily achieved by using onSelect event of dropdownbox. Values for first dropdownbox are obviously pre-decided, so you can use a simple java dictionary enumeration say "Country" and provide a value set for this simple type.

On onSelect event of the first dropdownbox, dynamically create an enumeration with required values and display to user. Using an enumeration of java dictionary for second and onwards dropdownboxes is not advisable as these values are immutable.

Hope this helps.

Regards,

Vishwas.

Former Member
0 Kudos

I did, well i'd use an anction for each dropdown in the following way:

I'll use pseudocode if you dont mind 😛

On Init

fill country dropdown

Country dropdown action


-Clear state dropdown
-Clear city dropdown

-Read selected country (current) and pass as parameter to the method/bapi/whatever in order to get the list of states
-Fill states dropdown

States Dropdown action


-Clear cities  dropdown

-Read selected state(current) and pass as parameter to the method/bapi/whatever in order to get the list of cities
-Fill cities dropdown

The actions of the "father" dropdown will always clear all the (sub) dropdowns dependant on him, and immediately fill the next dropdown.

Thats it, more or less.

Regards

Julio Herrera.

Former Member
0 Kudos

As I have written above I would suggest to use the onSelected Action.

E.g.

1) Add an onSelect to the Drop Down from the country

2) Enhance the hook method with your own code:

public void onActionCountrySelected(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

String selectedCountry = wdContext.currentContextElement().getCountry();

if(selectedCountry != null && !selectedCountry.equalsIgnoreCase("")) {

if(selectedCountry.equalsIgnoreCase("usa")) {

}

} else if(selectedCountry.equalsIgnoreCase("canada")) {

// ....

}

}

The dynamic binding of a drop down is explained in more detail [here|http://help.sap.com/saphelp_nw04/helpdata/en/74/450e8af57065468e88e4b86de47e4b/frameset.htm]

Kind regards,

Thierry

Former Member
0 Kudos

Thank you all for your valuable suggestions. I would design the solution using your inputs.

Thanks!

Vivek.