cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex - changing values

MG3
Contributor
0 Kudos

Hi

I have a table with 3 dropdowns, country, city and hotel.

This is my context node structure:


HotelTable (0...n)
    |_Dropdowns (1...n, Singleton:false)
         |_City (attribute, type:string)
         |_Country (attribute, type:string)
         |_Hotel (attribute, type:string)
    |_OtherField1
    |_OtherField 2

I am using dropdown by index. I create the first row and populate the dropdowns. I can see this list in the ui table, and it is correct.

In the table, when the user selects a country, it should refresh the city dropdown and the hotel dropdown.

How do I achieve this? I know in the dropdown by key, I can just get the valueset and update the entries. How do I do this here with dropdown by index? Do I create a new instance of the dropdowns node everytime the user changes something and then assign the values based on the country?

Any help will be appreciated.

Thanks

J

Message was edited by:

Jo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi manoj,

make the city & hotel attributes as calculated. it will generate getter & setter methods for u. In the setter u can access the country selected & set the values for city & hotel. No need to create instance everytime for dropdown nodes.

regards

Sumit

MG3
Contributor
0 Kudos

Hi Sumit

Thanks. Can you give me an example of what goes in the setter method? Preferably a code snippet?

Thanks

Former Member
0 Kudos

Hi jo,

Check this

<a href="http://help.sap.com/saphelp_nw70/helpdata/en/7f/a0384162316532e10000000a1550b0/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/7f/a0384162316532e10000000a1550b0/frameset.htm</a>

regards

Sumit

Answers (3)

Answers (3)

MG3
Contributor
0 Kudos

Hi all

Thanks so much for your guidance. I have solved the problem.

Instead of using this structure:

HotelTable (0...n)
    |_Dropdowns (1...n, Singleton:false)
         |_City (attribute, type:string)
         |_Country (attribute, type:string)
         |_Hotel (attribute, type:string)
    |_OtherField1
    |_OtherField 2

I used this:


*_HotelTable (0...n)_*
    |_*DropdownNodeCity (1...n, Singleton:false)*
         |_+City (attribute, type:string)+
     |_*DropdownNodeCountry(1...n, Singleton:false)*
         |_+Country (attribute, type:string)+
     |_*DropdownNodeHotel(1...n, Singleton:false)*
         |_+Hotel (attribute, type:string)+
    |_+OtherField1+
    |_+OtherField 2+

And used the regular way of populating it and setting the lead selection.

Thanks for all help, again.

Regards

J

Former Member
0 Kudos

Hi,

No you don't have to create a new instance of the dropdown node. Based on the selected country, you need to populate a simpleType to the attribute city and then similarly for the hotel. I mean to say, just populate the simpleType of the attrbute city again based on the country selected.

And offCourse you need to do this onAction of the country selected.

This will solve your problem.

thanks & regards,

Message was edited by:

Manoj

Manoj Kumar

MG3
Contributor
0 Kudos

Hi Manoj

you mean we can use a simpletype for dropdown by index too?

Thanks

Former Member
0 Kudos

Hi,

You have to bind an action to the country dropdown and instantiate the city and hotel node..

Kind Regards,

Saravanan K

MG3
Contributor
0 Kudos

Hi Saravanan

I have bound an action to the country dropdown, and I call a method which invalidates the dropdown node, gets all the data from the rfc node, and in a loop, i check if the country is the same as the country selected in the dropdown, then I create an element of the dropdown node and set city and hotel values.

It still does not work.

Thanks

Former Member
0 Kudos

Hi,

Could you kindly clarify the node structure for city and hotel ?

Regards,

Saravanan K

MG3
Contributor
0 Kudos

Hi Saravanan

City, Hotel and country are attributes under Dropdown node.

Thanks

MG3
Contributor
0 Kudos

Hi

This is what Im using now, and it changes the data for the other rows as well:


public void changeHotelList( )
  {
    //@@begin changeHotelList()
	String cityID = wdContext.currentHotelTableElement().currentDropdownsElement().getCityKey();
    
		wdContext.currentHotelTableElement().nodeDropdowns().invalidate();
	
		IPublicVcTrpHotelSearch.IHotelTableElement tableEl = wdContext.currentHotelTableElement();
		IPublicVcTrpHotelSearch.IDropdownsElement ddEl;
	
		for(int j=0;j<wdContext.nodeV_Hotel_List().size();j++)
		{
			ddEl = wdContext.createDropdownsElement();
	
			if(j==0 && wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Code().equalsIgnoreCase(cityID))
			{
				ddEl.setCityKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Code());
				ddEl.setCity(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Name());
				ddEl.setCountryKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getCountry_Code());
				ddEl.setCountry(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getCountry_Name());
				ddEl.setHotelKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getHotel_Id());
				ddEl.setHotel(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getHotel_Name());
			}

	
			else if(j>0 && wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Code().equalsIgnoreCase(cityID))
			{
				if(!wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Code().equalsIgnoreCase(
				wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j-1).getLocation_Code()))
				{
					ddEl.setCityKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Code());
					ddEl.setCity(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getLocation_Name());
				}
		
				if(!wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getCountry_Code().equalsIgnoreCase(
				wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j-1).getCountry_Code()))
				{
					ddEl.setCountryKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getCountry_Code());
					ddEl.setCountry(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getCountry_Name());
				}
		
				if(!wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getHotel_Id().equalsIgnoreCase(
				wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j-1).getHotel_Id()))
				{
					ddEl.setHotelKey(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getHotel_Id());
					ddEl.setHotel(wdContext.nodeV_Hotel_List().getV_Hotel_ListElementAt(j).getHotel_Name());
				}
			}

			tableEl.nodeDropdowns().addElement(ddEl);
		}
    //@@end
  }

Whats wrong here?

thanks