cancel
Showing results for 
Search instead for 
Did you mean: 

two dependent dropdownlist

Former Member
0 Kudos

dear all

i create to key dropdonlist that take their element from simple type built dictionary development component.

i need to know how to make them dependent so when for example i choose the usa element from the first dropdownlist the second dropdownlist show the states of usa

regards

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

dear Segmentation

could you pass the link for me because i cant find it

regards

junwu
Active Contributor
0 Kudos
IWDAttributeInfo attributeInfo = wdContext
				.nodeMatchingField()
				.getNodeInfo()
				.getAttribute(
						IPublicSLNCreationComp.IMatchingFieldElement.RELATIONSHIP_TYPE);

		ISimpleTypeModifiable tablesType = attributeInfo
				.getModifiableSimpleType();

		IModifiableSimpleValueSet valueSet = tablesType.getSVServices()
				.getModifiableSimpleValueSet();
		valueSet.clear();
//populate the states, and put them to vauleset
valueSet.put("","")

the code is an example, you have to adapt to your case, only some name change, i think.

Former Member
0 Kudos

dear all

i try to do everything you told me to do but nothing works

what im doing is i have to 2 simple types and make it as public parts

and bind this types to the view context

and i this working with me

but i need to make the second depend on the first i pend the hole day searching and trying to do this

but no result

so plz any one have any other idea

regards

Former Member
0 Kudos

- Define two DDIC types "Country" and "State" inside the IDE. Don't add values yet.

- Define context attributes "country" and "state" accordingly.

- Add DDByKey "CountrySelector" and "StateSelector" to your view.

- Bind the "selectedKey" properties of both DDByKey elements to "country" and "state".

- Assign an action "CountrySelected" to the "onSelect" event of the "CountrySelector"

- In wdDoInit() fill the value set of the "Country" type.

- In the action handler for "CountrySelected" check the value of the "country" context attribute and fill the value set of the "State" type depending on that value.

The code to fill a value set of a DDIC type can be found by searching this forum.

Former Member
0 Kudos

Hi Tareq

Please check this thread:

[]

It's about the matter of dependency between several dropdowns.

Regards

former_member218672
Active Contributor
0 Kudos

Hi Tareq,

do code like below. cosider you have 2 dropdown fileds country and state. 1st take country in the context parameter, like below -

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

then take state in the 2nd property paramer like above - String sState = wdContext.currentContextElement().getState();

then use for loop like - for(int i=0; i<sState .size(); i++) - in it, populate the states corresponding to the country using java, it would require some sort mechanism.

you'll get this type of code in google.

Regards,

Sen

Former Member
0 Kudos

dear

plz explain how could i do this

im new to sap developer studio

regards

Former Member
0 Kudos

Hi,

Please select the key from the first dropdown and based on it load the second dropdown.

if you are using DDBI follow the thread

Regards

Saravanan K

Former Member
0 Kudos

dear

i know

but i need the code because i dont know how to write it

i dont want to give the second dropdownlist element from an array i define

i want this dropdownlist take spicific element from the simple type

regards

Former Member
0 Kudos

If you use DDByKey you can populate the second drop-down list in the "onSelect" action handler of the first drop-down list. Populating a DDByKey can be done by populating the value set of the DDIC type of the context attribute to which the DDByKey is bound.

former_member185879
Active Contributor
0 Kudos

Hello Tareq,

Your values should be like this to filter.

CountryNode.

IN India

USA America

AUS Australia

StateNode

IN KA Karnataka

IN TN Tamil Naud

IN KL Kerela

IN DL Delhi and so on for USA and AUS.

so in first drop down if you select India then get the key value "IN" by using

String Country = wdContext.currentCountryNodeElement().getCountry().

IprivateSampleView.IStateDDNodeElement element;

for(int i=0;i<wdContext.StateNode().size();i++)

{

if(wdContext.nodeStateNode().getStateNodeElementAt(i).equalsIgnoreCase(Country);

{

element = wdContext.createStateDDNodeElement();

element.setState(wdContext.nodeStateNode().getStateNodeElementAt(i).getState();

wdContext.nodeStateDDNode().addElement(element);

}

}

StateDDNode is the one you are going to bind to Second Drop Down.

Rever for any queries.

Regards

Nizamudeen SM

junwu
Active Contributor
0 Kudos

I think it's all up to you,

you can put the code in onSelect event of the first dropdown to manipulate the data of second dropdown