cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown content changing on Selection of Another dropdown in table

Former Member
0 Kudos

hi

i have a problem, In my scenario i have two drop down in table.

1) Initially first drop down contains the country names and second dropdown contains the state names.

2) Whenever I select country the content of the second dropdown will change like it contains the names of states in that particular country for that particular row.

3) If I select a state in then the first dropdown will contain the name of particular country that contains the state.

4) Table contain 10 rows and initial drop downs in each row willcontain all values.

could you please help me in solving this problem. i don't know which method i have to use(BY KEY or BY INDEX)

Regards

Pradeep P N

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hai,

Suppose you have ,Attribute Country asigned to dropdownby key.

create an action for OnSelect.

in code

String countrySelected=wdContext.currentcontextElement().getCountry;

String states[]=getStates(Country);

bind it to another dropbykey

regards,

Naga

Former Member
0 Kudos

hi

we can keep the values in string array, but when making changes in one drop down will affect the values in drop downs of all rows. what i have to do in that case?

Regards

Pradeep

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

you have to do that programmatically,

in OnSelect of coutry dropdown you need to write a code which will modify the simple type (hope you are going for simple type and dropdownbykey) associated with the context attribute of the other cell editors.

flow:

1)create a simple type in dictionary

2)to whicever context attribute the cell editor is mapped , make datatype of context attribure to the dictionary simpel type

3)so on action of OnSelect of country dropdown , perforn the action that will modify the simple type , ie populate the other dropdown with the relevant fields.

code for this you will get in the tutorial of my earlier post.

hope it helps

regards

abhijeet_mukkawar
Active Contributor
0 Kudos

Pradeep,

check this for difference and clear understanding of them,

so if your data is coming from r3 or web service , use byIndex otherwise if you know how many countries and their state are then better to create simple type of them and use ByKey. In this also you can add runtime data, refer this tutorial for that:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/value%20...

for dropdownbyindex code , refer following code, and code sonething like this in your application:



IPublicGetList.IIt_Team_Lst3Node team_node = wdContext.nodeIt_Team_Lst3(); // this node holds the data from backend
team_node.moveFirst();


int size = team_node.size();
for (int i = 0; i < size ; i++)
{
IPublicGetList.ICtx_vn_teamsNode teams = wdContext.nodeCtx_vn_teams(); .//this is the context node in which you will
// populate the backend data and one of its attribute is mapped 
//with dropdownbyindex ui element , so that ui element will show all 
//populated values.
teams.moveFirst();
exists = false;

IPublicGetList.ICtx_vn_teamsElement iteamtab_element = wdContext.nodeCtx_vn_teams().createCtx_vn_teamsElement();
iteamtab_element.setCtx_va_team_desc(team_node.currentIt_Team_Lst3Element().getTeam_Desc());
iteamtab_element.setCtx_va_team_id(team_node.currentIt_Team_Lst3Element().getTeam_Id());
wdContext.nodeCtx_vn_teams().addElement(iteamtab_element);
team_node.moveNext();
}

create on dropdownbyindex UI element in layout and set its property to one of the value attribute of context value node Ctx_vn_teams(it has two value attrib "id" and its "desc.")

whichever action you want to take , you can put code for the same in <b>OnSelect</b> action of both of them, so when anything will be selected that action will be performed.

hope it helps

let me know if you face any problem

regards