cancel
Showing results for 
Search instead for 
Did you mean: 

Display dropdown by key data with sorting

former_member442169
Participant
0 Kudos

Hi,

My requirement is to display dropdown by key data with sorting getting this data from XML in KM.

Tell me different possibilities to sort the data.

Regards,

surya.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member442169
Participant
0 Kudos

self

Former Member
0 Kudos

Hi,

Use DropDownByIndex instead of DropDownByKey

Create a node with a attribute for eg. Colors node with Color attribute and add the values in the elements of the node, Bind attribute to DropDownByIndex UI.

Create a custom comparator class like below

import java.util.Comparator;

import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
import com.sap.tc.webdynpro.progmodel.repository.enums.WDComponentLifecycleEnumInfo;

public class CustomComparator implements Comparator {
	String attribute; 
	public CustomComparator(String attrib) {
		this.attribute = attrib;
	}

	public int compare(Object o1, Object o2) {
		try
		{ 
			IWDNodeElement units1 = (IWDNodeElement) o1;
			IWDNodeElement units2 = (IWDNodeElement) o2;
			return units1.getAttributeAsText(attribute).compareTo(units2.getAttributeAsText(attribute));
		} 
		catch (Exception e)
		{
			e.printStackTrace();
		}
		//arbitrary order
		return 1;
	}

}

Once you read values in the Colors node, call the sortElements method of the node as below to sort the elements of the node

wdContext.nodeColors().sortElements(new CustomComparator("Color"));

Regards,

Amol

Former Member
0 Kudos

hi,

You have to use Treemap for sorting the data.

Refere also below links

Edited by: Abhilasha Dahare on Jan 10, 2011 12:36 PM

Edited by: Abhilasha Dahare on Jan 10, 2011 12:42 PM

former_member218672
Active Contributor
0 Kudos

Hello Surya,

Try to use DropDOwnByINDex in the table ui elemnt and also check this article

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c03227f9-e48f-2c10-4bad-8ebdec704f3d

hope it helps.

Regards,

Sen