cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down - How to display both Values and Description

Former Member
0 Kudos

Hi Experts,

I have created WD Program which fetches following data from R/3:

Code Description

AR Arizona

NY New York

NJ New Jersey

I have created 'Drop Down by Index' UI element. Using the usual mapping I can display either Code or Description. However, as per client requirement I have to display both Code and Description i.e.

AR: Arizona

NY: New York

NJ: New Jersey

I tried few methods. But it is not working.

Please help.

Regards,

Gary

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

Hello Gary,

Create a copy of the model node in the view controller and then fill it as shown in the code below:-

  int size = wdContext.nodeCountrylist_out().size();
   String descp = "",code = "", descp_new = "";
   for (int i = 0; i < size ; i++)
   {
   	IPrivateTest1.ICountrylist_out_1Element cpyel = wdContext.createCountrylist_out_1Element(new Countries());
   	
   	 
   	 descp = wdContext.nodeCountrylist_out().getCountrylist_outElementAt(i).getdesc();
	 code  = wdContext.nodeCountrylist_out().getCountrylist_outElementAt(i).getcode();                    
	 descp_new = code + ":" + descp;
     cpyel.setcode(code);
   	 cpyel.setLandx(descp_new);
   	 wdContext.nodeCountrylist_out_1().addElement(cpyel);
   }

hope this will hep.

Regards,

Sarbjeet

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gary,

Follow the steps.

1. Create value node Vn_Region.

2. Create 3 attributes within Va_Code, Va_Name and Va_Desc.

3. In the code to get code and name from R3, set Va_Desc as Code+Name.

String name,code,desc;

for(int i=0;i<wdContext.node<REG>().size();i++){

code=wdContext.node<REG>() .get<REG>ElementAt(i).get<code>();

name=wdContext.node<REG>() .get<REG>ElementAt(i).get<name>();

desc= code + " , " + name;

}

Regards,

Tushar Sinha

Former Member
0 Kudos

Hello,

Try this: create value node - create the ID attribute and the description. The ID should be the ID from the data you got from R3 - then just loop through the model node and append the data you want.

Bind the drop down with this node.

I'm not sure if there's a quicker way though. Goodluck.

Regards,

Jan

Former Member
0 Kudos

Hi Jan,

Can you kindly provide me some sample code for looping as mentioed in your reply.

Regards,

Gary

Former Member
0 Kudos

Hi Gary

Calculate the size of the model node.

Now loop through this node.

In the node to which your drop down is bound, have an attribute say va_combined.

In your loop set va_combined = code+description OR desccripion +code (description and code come from the model node)

Bind the text property of your drop down to this va_combined.

Regards,

Himanshu

Former Member
0 Kudos

I don't have NWDS to assist but it should go like this

int size = wdContext.nodeRFCNode.size();
String stateID = "";
String description = "";

for(int i = 0; i < size; i++){
    stateID = wdContext.nodeValnode().getElementAt(i).getAttributeValue("stateID");
    description = wdContext.nodeValnode().getElementAt(i).getAttributeValue("description");
    //set the value here to that value node containing the joined String
}

Good luck!

Regards,

Jan